How can I remove the Default selection in Listbox GUI?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
I always see the top option in the listbox is default selected. How to remove this default selection?

Please help me. I checked the property inspector but couldn't find any solution. Thanks!
Accepted Answer
If you'd rather have the 2nd one as default set the 'Value' property to 2.
If you want there to be no default, set the 'Value' property to an empty matrix and set the 'Max' and 'Min' properties to satisfy the following condition:
Max - Min > 1
10 Comments
Vinayak Appasaheb Bhatte
on 20 Jul 2018
Thanks adam! I get a warning when I set the value property to 0x0 array. Is that fine?
Adam Danz
on 20 Jul 2018
What does the warning say? When do you get the warning - when you open the GUI? I just tried it on one of my GUIs and it worked fine.
Vinayak Appasaheb Bhatte
on 20 Jul 2018
Warning: Multiple-selection 'listbox' control requires that 'Value' be an integer within Character vector range Control will not be rendered until all of its parameter values are valid.
I put the size of the matrix as 0x0 in value property. Default size was 1x1
Image Analyst
on 20 Jul 2018
Like it says, the value property of the listbox cannot be 0. It must be between 1 and the number of items in the listbox.
Vinayak Appasaheb Bhatte
on 20 Jul 2018
Alright, Thank you so much for the help!
Adam Danz
on 20 Jul 2018
Set value with an empty matrix like this.
'Value',[]
Adam Danz
on 20 Jul 2018
For example
figure
uicontrol('style', 'listbox', ...
'string', {'a' 'b' 'c'}, ...
'value', [], 'min', 1, 'max', 10, ...
'units', 'normalize', ...
'position', [.5 .5 .1 .3])
Vinayak Appasaheb Bhatte
on 20 Jul 2018
I have set the callback function directly by placing the listbox in gui. I don't think so I set value as [] inside by callback function.
Adam Danz
on 20 Jul 2018
You need to set that value either 1) when you are creating the listbox (as in my example) or 2) in the properties menu if you're using GUIDE.
You can also change the 'value' setting any time by using the handle to the listbox.
either
lb.Value = [];
or
set(lb, 'Value', [])
Vinayak Appasaheb Bhatte
on 20 Jul 2018
Thanks Adam :)
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
See Also
on 18 Jul 2018
on 20 Jul 2018
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)