Appdesigner get Index and String from DropDownMenu
51 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
Is there a way I can get the index and the string in a dropdown menu selection?
I had the idea to set up this pice of code in the openinfunction to change the DropDown.Value to the index
app.DropDown.ItemsData=1:numel(app.DropDown.Items);
Later I would get the index with
val = DropDown.Value;
and the string with
Str = DropDown.Items{val};
Do you know of a better way since my method seems to be too complicated. Thanks for any help!
Regards J.
0 个评论
回答(1 个)
Voss
2023-2-23
If you need the index and the string, then the way you're doing it is good.
If you just need the string, you should do away with ItemsData and just do
Str = DropDown.Value;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!