How do I disable a dropdown option?

On my GUI on the appbuilder I have two dropdown menus with the same options, app.dropdown1 and app.dropdown2. Their Items are a1, a2, a3, and a4. How can I make it so that if I choose an item on dropdown1 it turns the visibility of it off on dropdown2.
Desired output: if dropdown1's value = a1 on dropdown2 only (a2,a3,a4) should be visible

回答 (1 件)

Voss
Voss 2021 年 9 月 28 日

1 投票

str = app.dropdown1.String; % store dropdown1's list of options
str(app.dropdown1.Value) = []; % remove the selected one
app.dropdown2.String = str; % apply it to dropdown2
Run those lines in dropdown1's Callback function. You probably also want to update app.dropdown2's Value property.

3 件のコメント

hbcukid
hbcukid 2021 年 9 月 29 日
I got an error
Unrecognized method, property, or field 'String' for class 'matlab.ui.control.DropDown'.
Kevin Holly
Kevin Holly 2021 年 9 月 29 日
try app.dropdown1.Items instead of String
hbcukid
hbcukid 2021 年 9 月 29 日
Matrix index is out of range for deletion

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2021 年 9 月 27 日

コメント済み:

2021 年 9 月 29 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by