In appdesigner how to select radio button from code?

32 vues (au cours des 30 derniers jours)
Tamas Muszbek
Tamas Muszbek le 4 Avr 2017
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?

Réponses (1)

Cris LaPierre
Cris LaPierre le 7 Nov 2018
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 commentaires
Jignesh Solanki
Jignesh Solanki le 8 Mai 2022
Modifié(e) : Image Analyst le 8 Mai 2022
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 le 8 Mai 2022
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by