Enable/disable on radio button in app designer

12 ビュー (過去 30 日間)
Jim McIntyre
Jim McIntyre 2025 年 6 月 25 日
コメント済み: Jim McIntyre 2025 年 6 月 30 日
In App Designer, I have created a radio button group with three buttons. The buttons select which set of data to graph. Call the three buttons Choice1, Choice2, and Choice3.
If a certain selection of other controls is made in the app, I want to disable the Choice2 and Choice3 buttons and force the selected button to be Choice1.
If different set of selections is made, I want to re-enable the other Choice2 and Choice3 buttons and allow them to be selected.
Is it possible to do this? If so, how?

採用された回答

Walter Roberson
Walter Roberson 2025 年 6 月 25 日
You can create app.bg as a uibuttongroup and populate it with uiradiobutton .
Later, you can
bc = [app.bg.Children];
set(bc(1:end-1), 'Enable', 'off')
bc(end).Enable = 'on';
app.bg.SelectedObject = bc(end);
to enable the first button and disable the other objects.
To restore,
bc = [app.bg.Children];
set(bc, 'Enable', 'on');
app.bg.SelectedObject = bc(end);
  3 件のコメント
Walter Roberson
Walter Roberson 2025 年 6 月 25 日
You could set the UserData property of each of the button children, set it to an index. Then
app.bg.SelectedObject.UserData
would give you the index
Or you could
[tf, idx] = ismember(app.bg.SelectedObject, app.bg.Children);
and then if tf is true, idx would be the index in reverse creation order (e.g, if there were 3 children then index 3 would correspond to the first created.)
Jim McIntyre
Jim McIntyre 2025 年 6 月 30 日
Thank you for the additional suggestions.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by