How can I select multiple items from a GUI listbox?
76 views (last 30 days)
Show older comments
MathWorks Support Team
on 21 Jun 2013
Edited: MathWorks Support Team
on 17 May 2023
How can I select multiple items from a GUI listbox?
Accepted Answer
MathWorks Support Team
on 17 May 2023
Edited: MathWorks Support Team
on 17 May 2023
To select multiple items in a List box the Max and Min properties must be defined. If Max - Min > 1, then list boxes allow multiple item selection. If Max - Min <= 1, then list boxes do not allow multiple item selection. Please refer to the documentation page for Max and Min for the List box in the following link:
An example for creating a List box that allows multiple item selection is created with the commands below:
txt_cell_array = {'line1';'line2';'line3';'line4';'line5'};
h_list = uicontrol('style','list','max',10,...
'min',1,'Position',[20 20 80 60],...
'string',txt_cell_array);
Notice that the UICONTROL function creates the List box, as per its documentation page:
For a list of additional properties for the UICONTROL please refer to the following documentation page:
Note that if you currently have a List box available, to enable multiple item selection you need to set the Max and Min properties of this List box via its handle.
set(h_list,'Max',2,'Min',0);
The above command allows a maximum number of two selections in the List box with handle "h_list". To dissable multiple item selection on the List box, set the properties as follows:
set(h_list,'Max',1,'Min',0);
0 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!