How can I enable/disable a item in a dropdown in matlab app designer?

27 ビュー (過去 30 日間)
Eric
Eric 2024 年 3 月 19 日
回答済み: Ramtej 2024 年 3 月 20 日
How do i make an item from a drop down disable to the user. Where its greyed out and can't be selected? Is that possible in matlab?
Thanks,
Eric

回答 (1 件)

Ramtej
Ramtej 2024 年 3 月 20 日
Hi
Currently MATLAB does not provide a direct way to disable individual dropdown items.
You can try an alternative workaround as shown below:
  • Add the style to the drop-down component item to change its background color to grey.
s1 = uistyle("BackgroundColor","#808080");
addStyle(app.DropDown,s1,"item",1);
  • Check the selected item in the dropdown's callback function and revert to a previous selection or display a message if a "disabled" item is selected.
Note: This workaround does not make the the option unclickable.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by