Reputation: 1102
I want to get how many strings exist in the popup menu, how can this be done? This code that I have written does not seem to work.
length(get(handles.popupMenu,'Value'))
Upvotes: 0
Views: 185
Reputation: 65430
Value
is the index of the currently selected item in the menu so it will only ever be a scalar. You instead want to check the length of the String
property which contains a cell array of strings (one for each item).
nOptions = numel(get(handles.popupMenu, 'String'));
Upvotes: 2