App Designer ListBox and DropDown selection number
20 次查看(过去 30 天)
显示 更早的评论
Hi All
I'm a GUIDE user but am now doing my first major GUI with App Designer (in 2017b), due to a nudge from Mathworks.
In GUIDE, the current selection number of a ListBox is extracted by handles.ListBox.Value (and for a DropDown, it is handles.DropDown.Value). In App designer the 'Value' field has been changed to output the content string of the selected entry and not the number of that entry. I can't find any field giving me the number? (which seems a step backwards to me in the context of vectorized code being the way to go)
Currently, I am awkwardly finding the number with strcmp inside a for loop.
for i = 1:length(app.DropDown.Items)
if strcmp(app.DropDown.Items{i},app.DropDown.Value)
break
end
end
SelectNum = i;
How do I obtain the number in a quick way?
Thanks in advance
0 个评论
采纳的回答
Ashutosh Prasad
2018-8-24
Hello
You can use the ItemsData property of the app.DropDown class to specify whether you want the app.DropDown.Value to be numeric or string.
If you want numeric values just change the above code fragment with the following code snippet
>> app.DropDown.ItemsData = 1:length(app.DropDown.Items)
>> SelectNum = app.DropDown.Value;
Let me know if this works for you
2 个评论
更多回答(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!