Using the selected string of listdlg not the index number
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Guillaume
2017-3-17
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!