Borrar filtros
Borrar filtros

how to clear all selected listbox items

31 visualizaciones (últimos 30 días)
shaz
shaz el 26 de Oct. de 2012
Comentada: Image Analyst el 15 de Abr. de 2016
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

Respuesta aceptada

Image Analyst
Image Analyst el 26 de Oct. de 2012
shaz, doing
set(handles.yourListbox, 'Value', []);
used to work in older versions, and I did use it. Why? For example if you loaded a listbox with files, selected a high number (say 20), and then changed folder and reloaded the listbox and it had fewer files, the listbox would vanish if there were fewer files than the number you selected. For example the new listbox had only 19 items and your "Value" property was still at 20. So what I did was to deselect all by setting the value property to []. However they made some change a few versions ago and this no longer worked. I had to set the value equal to 1. But that still selected an item and sometimes you don't want an item selected. For example it might imply that some things displayed on your GUI apply to that selected item, when they don't.
However the good news is that setting the value to [] now works again, as of R2012b. I just tested it to verify, and it works again! Please upgrade to that version.

Más respuestas (2)

Jan
Jan el 26 de Oct. de 2012
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
Azzi Abdelmalek el 26 de Oct. de 2012
set(handles.yourlistbox,'enabled','off')
  2 comentarios
Lockywolf
Lockywolf el 15 de Abr. de 2016
An uicontrol has no "enabled" property.
Image Analyst
Image Analyst el 15 de Abr. de 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).

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by