How can I select multiple items from a GUI listbox?
82 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2013-6-21
编辑: MathWorks Support Team
2023-5-17
How can I select multiple items from a GUI listbox?
采纳的回答
MathWorks Support Team
2023-5-17
编辑:MathWorks Support Team
2023-5-17
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!