how to clear all selected listbox items
Show older comments
i have a list box containing 20 items if i have selected 10 items now if i push button all selected list box needs to cleared
setting valuue property to [] makes listbox dissappear
Accepted Answer
More Answers (3)
Josh Kahn
on 29 May 2025
If you receive this error:
Error using matlab.ui.control.internal.model.ExactlyOneSelectionStrategy/validateValuePresentInItemsData (line 238)
'Value' must be an element defined in the 'ItemsData' property.
then try using an empty cell array instead:
listBox.Value = {}
Jan
on 26 Oct 2012
0 votes
Is the disappearing accompanied by a warning message? Please post the corresponding code, because a minimal example, which reproduces your problem, will clear, what you are actually doing. A textual descritpion usually does not contain the bug, which causes the troubles.
In other words: The actual question is: Why does setting Value to [] make the listbox invisible? This is not the expected behavior.
Azzi Abdelmalek
on 26 Oct 2012
set(handles.yourlistbox,'enabled','off')
2 Comments
Lockywolf
on 15 Apr 2016
An uicontrol has no "enabled" property.
Image Analyst
on 15 Apr 2016
What type of control are you referring to? Listboxes, buttons, checkboxes, radio buttons, edit fields, etc. all most certainly do have an enable property (though setting it to off will not deselect highlighted items in a listbox).
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!