In appdesigner how to select radio button from code?

55 次查看(过去 30 天)
I want to force a radio button in a button group selected by code.
I tried overwriting the SelectedObject property of the group, or the Value property of the buttons, but in the GUI nothing seems to change. The originally selected button does not behave like selected anymore once I overwritten the properties, but the user sees it as selected and it is confusing.
So how can I set the button in a way that it changes in the GUI display as well?

回答(1 个)

Cris LaPierre
Cris LaPierre 2018-11-7
In appDesigner, you can change the value property of the button you want to have selected.
To test, I created a new app and added a Radio Button Group. This adds three radio buttons with names button, button2 and button3. The first radio button is selected by default. I also added a Button with a callback function containing the following code:
app.Button2.Value = 1;
When I press the button, it sets the value of button2 to 1. The Radio Button Group will automatically deselect the first radio button and show the second as selected.
  3 个评论
Jignesh Solanki
Jignesh Solanki 2022-5-8
编辑:Image Analyst 2022-5-8
Please can anyone let us know how to deselect all radio button at once and select all radio button at once? The current program always keep one radio button selected all the time.
I am using MATLAB 2022 app designer version.
Image Analyst
Image Analyst 2022-5-8
I don't believe you can have all of the items in a radio button group be selected or deselected. To do that you'd have to have a group of checkboxes. Then you can select or deselect them all independently.
If you want you can also write the callback for one of the checkboxes to select or deselect one or more of the other checkboxes.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by