[GUI] How do you get only one element in a listbox

2 visualizaciones (últimos 30 días)
Shane
Shane el 17 de Dic. de 2012
I know you are able to obtain all the elements in a string from the listbox with:
get(handles.listbox1, 'String')
But what if I only want the second or fourth element in the listbox?
Thanks in advance <3

Respuesta aceptada

Image Analyst
Image Analyst el 17 de Dic. de 2012
You have to read in the whole thing anyway. Then get the value property and use that to index into the string.
listboxItems = get(handles.listbox1, 'string');
selectedItems = get(handles.listbox1, 'value');
selectedItem = listboxItems(selectedItems);
  4 comentarios
Walter Roberson
Walter Roberson el 17 de Dic. de 2012
Change
listboxItems = get(handles.listbox1, 'string');
to
listboxItems = cellstr( get(handles.listbox1, 'string') );
Shane
Shane el 17 de Dic. de 2012
Thank you soo much Walter I appreciate it!!!

Iniciar sesión para comentar.

Más respuestas (0)

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