appdesigner button group problem

21 ビュー (過去 30 日間)
Yu Li
Yu Li 2019 年 1 月 8 日
コメント済み: Eric Sargent 2020 年 12 月 9 日
I have a radio button and I want to set its 'Enable' property as 'off' in a specified situation, but Matlab report error as:
No appropriate method, property, or field 'Enable' for class 'matlab.ui.container.ButtonGroup'.
this feature should be available in others such as drop down list, etc.
is there any mistake with my operation?
Bests,
Yu
  1 件のコメント
Eric Sargent
Eric Sargent 2020 年 12 月 9 日
As of R2020b ButtonGroup and Panel both support Enable when the button group or panel is parented to a uifigure.

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

採用された回答

Kojiro Saito
Kojiro Saito 2019 年 1 月 9 日
Enabled property is not valid for Button Group but valid for Button. So, app.Button.Enable = 'off' will work.
%% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create ButtonGroup
app.ButtonGroup = uibuttongroup(app.UIFigure);
app.ButtonGroup.Title = 'Button Group';
app.ButtonGroup.Position = [282 115 123 106];
% Create Button
app.Button = uiradiobutton(app.ButtonGroup);
app.Button.Enable = 'off';
app.Button.Text = 'Button';
app.Button.Position = [11 60 58 22];
app.Button.Value = true;
% Create Button2
app.Button2 = uiradiobutton(app.ButtonGroup);
app.Button2.Enable = 'off';
app.Button2.Text = 'Button2';
app.Button2.Position = [11 38 65 22];
% Create Button3
app.Button3 = uiradiobutton(app.ButtonGroup);
app.Button3.Text = 'Button3';
app.Button3.Position = [11 16 65 22];
%% Disable all buttons
app.Button.Enable = 'off';
app.Button2.Enable = 'off';
app.Button3.Enable = 'off';
Also, Button Group has Visible property, so you can hide button group by the following.
app.ButtonGroup.Visible = 'off';
  1 件のコメント
Yu Li
Yu Li 2019 年 1 月 9 日
Thank you!
Bests,
Yu

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

その他の回答 (1 件)

Eric Sargent
Eric Sargent 2020 年 12 月 9 日
As of R2020b ButtonGroup and Panel both support Enable when the button group or panel is parented to a uifigure.

カテゴリ

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by