Using the selected string of listdlg not the index number
10 views (last 30 days)
Show older comments
Hi,
I'm currently trying to find a way to use the string selected when using listdlg, not the index number it provides through the selection output.
So for example:
I somebody selects 'cat,' which is the third option in the list - instead of just getting the value 3, is there anyway to have it output the 'string' cat?
I am wanting the output of that selection to be used in a function, so just having the index value doesn't help.
Does anybody know a way to do this?
0 Comments
Answers (1)
Guillaume
on 17 Mar 2017
Well, since you obviously have the ListString you passed to listdlg in the first place, just use the returned index to retrieve the selected value(s) from that list:
somelist = {'cat', 'dog', 'fish'};
[selectionindex, ok] = listdlg('ListString', somelist);
if ok
selectedvalues = somelist(selectionindex);
%do something with selectedvalues
end
0 Comments
See Also
Categories
Find more on Matrix Indexing 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!