How can I set my list box to have no default selection in MATLAB?

10 views (last 30 days)
I would like to set my list box such that none of its items are highlighted upon creation.
I tried using the following code to set the "Value" property of the list box to an empty matrix. However, instead of seeing the desired result, the list box disappears.
item_list = {'L1';'L2';'L3';'L4';'L5'};
h = uicontrol('style','list','Position',[40 40 80 70],...
'string',item_list, 'Value', []);

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
You can set your list box to have no selection by setting the 'Value' property to an empty matrix and setting the 'Max' and 'Min' properties to satisfy the following condition:
Max - Min > 1
The above condition enables multiple selection.
For example:
item_list = {'L1';'L2';'L3';'L4';'L5'};
h = uicontrol('style','list','max',2,...
'min',0,'Position',[40 40 80 70],...
'string',item_list, 'Value', []);

More Answers (0)

Categories

Find more on Interactive Control and Callbacks 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!