Get selection index for DropDown object using AppDesigner
62 ビュー (過去 30 日間)
古いコメントを表示
Using AppDesigner, how do I access the selected index of a DropDown menu. The Value is the selected string but I can't find anywhere that indicates the selected index. Instead I seem to have to do:
I = find(strcmp(h.Items,h.Value));
Is this really the suggested approach?
0 件のコメント
採用された回答
Matt J
2017 年 11 月 10 日
編集済み: Matt J
2017 年 11 月 10 日
The h.Value property has different behavior depending on how h.Items and h.ItemsData are set up. If you define the ItemsData property to be some sequence of numeric indices i=1:N, then h.Value will be the numeric value of i corresponding to the selection.
15 件のコメント
Erik
2021 年 2 月 19 日
Thanks on the info on how to get access to a running app.
There is no way in my version to enter the ItemData so that it becomes a numerical array. What ever I do in de compent inspector, the end result is the same (see below). And yes the (single) Value is shown in the inspector as numbers under each other while the ItemData is shown as 1,2,3,4
But, like I said, in the 2020b version, this behaviour fortunately changed apparently
>> app.DropDown
ans =
DropDown (Option 1) with properties:
Value: '1 2 3 4'
Items: {'Option 1' 'Option 2' 'Option 3' 'Option 4'}
ItemsData: {'1 2 3 4'}
Editable: 'off'
ValueChangedFcn: ''
Position: [131 192 100 22]
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!