How to implement logical structure in Radio Button Group with GUI

1 visualizzazione (ultimi 30 giorni)
Hey Guys,
I am new to GUI Programming and i implemented a Radio button structure as follows:
now i try to implement a logical structure in there. I want the 'Local' Checkbox to be inactive first. and then i want it to be activated as soon as there is any of the 3 options of the radio buttons activated. There can be activated all 3 radio buttons, so it is not exclusive. But as soon as no radio button is checked, the 'Local' Checkbox shall be unchecked again too.
I tried to do it like this
if (handles.onlypvdroop_control==1 || handles.onlyunbalance_control==1 || handles.onlylala_control==1)
set(handles.local_control,'Value',1)
else
set(handles.local_control,'Value',0)
end
this doesnt give an error but doesnt work either.
What is the problem, HOw can i make it work?
I am very glad for your help Best regards, busta x

Risposte (1)

Geoff Hayes
Geoff Hayes il 12 Set 2015
busta x - your condition is comparing the handle for each radio button to 1, and not comparing the value of the radio buttons. So something like this would be the correct form for your condition
if get(handles.onlypvdroop_control,'Value')==1 || get(handles.onlyunbalance_control,'Value') ==1 || get(handles.onlylala_control,'Value')==1
The above will only fix part of the problem though because of your requirement that all three radio buttons can be activated or that all radio buttons can be unchecked. If you have a group of radio buttons (like you do) then exactly one should be set/on at any one time and never more than one (this is typical radio button behaviour). If you want to allow the user to turn on more than one or have all of them off, then you should be using check boxes instead.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by