Unable one of the options of drop down

Hi, please help me!
I wanna disable one of the options of drop down 2 when i chose a particular option on drop down 1. what should the codes be?

 採用された回答

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath 2023 年 9 月 7 日
編集済み: Mrutyunjaya Hiremath 2023 年 9 月 7 日

0 投票

You can use 'set' to change the 'Enable' property of the dropdowns in the callback functions.
Here's how you can modify the code to include lines -
% Callback function for the first dropdown
function firstDropdownCallback(~, ~)
% Disable the second dropdown
set(secondDropdown, 'Enable', 'off');
% Enable the first dropdown (in case it was disabled)
set(firstDropdown, 'Enable', 'on');
end
% Callback function for the second dropdown
function secondDropdownCallback(~, ~)
% Disable the first dropdown
set(firstDropdown, 'Enable', 'off');
% Enable the second dropdown (in case it was disabled)
set(secondDropdown, 'Enable', 'on');
end

3 件のコメント

Amron
Amron 2023 年 9 月 8 日
thanks for your answer. but, what i mean is how i could disable an option in my second dropdown, not disabling the dropdown itself. let say if i chose "option 1" on my first dropdown (drop down 1), the option "3" in my second dropdown (drop down 2) is disabled. so, if i chose "option 1" on my first dropdown, i can't chose option "3" but i can chose option "1", "2", or "4" on my second dropdown.
Mario Malic
Mario Malic 2023 年 9 月 8 日
You will have to remove the dropdown item, otherwise try with button group component.
Amron
Amron 2023 年 9 月 10 日
編集済み: Amron 2023 年 9 月 10 日
So, i can't disable one of the options of my dropdown without delete it? Okay thanks bro, i'll try the button group

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import and Export についてさらに検索

製品

リリース

R2022a

質問済み:

2023 年 9 月 7 日

編集済み:

2023 年 9 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by