List Box in GUI

1 visualización (últimos 30 días)
shaz
shaz el 30 de Mzo. de 2012
How to get the index of elements from the list box of not selected items from list box.
Usually list box gives elements index of selected items using property values

Respuesta aceptada

Image Analyst
Image Analyst el 30 de Mzo. de 2012
Try this (untested):
% Get list of all of the filenames in the list,
% regardless of whether they are selected or not.
ListOfImageNames = get(handles.lstImageList, 'string');
numberOfItems = length(ListOfImageNames);
% Get the index(es) of the entry they've selected.
Selected = get(handles.lstImageList, 'value');
% Get the index(es) of the entry they've NOT selected.
notSelected = find(~ismember(1:numberOfItems, Selected))

Más respuestas (1)

Titus Edelhofer
Titus Edelhofer el 30 de Mzo. de 2012
Hi,
you could do the following if I understood the question correclty:
allStrings = get(handles.listbox1, 'string');
selected = get(handles.listbox1, 'value');
% all indices:
allIndices = 1:length(allStrings);
% now subtract:
unselected = setdiff(allIndices, selected);
Titus Titus

Categorías

Más información sobre Loops and Conditional Statements 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