Main Content

setSelectedItems

Class: Simulink.dialog.ListboxControl
Namespace: Simulink.dialog

Set values for a list box

Syntax

setItems = listboxControl.setSelectedItems({string1','string2',...})

Description

setItems = listboxControl.setSelectedItems({string1','string2',...}) sets the values for the selected items in the list box.

Input Arguments

expand all

Handle to the list box, specified as an object. You can use the getDialogControl command to get the list box handle. For more information, see getDialogControl.

For example, litboxControl = maskObj.getDialogControl('listboxname'). Here, maskObj is the mask object and listboxname is the name of the list box.

Data Types: cell array

Value to be set for selected items in the list box

For example, 'Hello'.

Examples

% Get block mask handle
maskObj = Simulink.Mask.get(gcb); 

% Get listbox handle
listboxControl = maskObj.getDialogControl('Control2');

% Set selected items
listboxControl.setSelectedItems({'Hello','World'}); 

Version History

Introduced in R2019a