how to manage radiobuttons?
2 ビュー (過去 30 日間)
古いコメントを表示
Jihad Chamseddine
2014 年 7 月 30 日
コメント済み: Jihad Chamseddine
2014 年 7 月 31 日
i have 2 radiobuttons, when i click on radio 1 and i then click on radio 2, radio 1 stays checked and thats not what i want, i want when one of the two radiobuttons are clicked the other should be unchecked immediately thanks
0 件のコメント
採用された回答
Geoff Hayes
2014 年 7 月 30 日
Jihad - You can put the two (or more) radios buttons within a Button Group widget. Clicking on one radio button (within this widget) will automatically turn off the other (and vice versa).
3 件のコメント
Geoff Hayes
2014 年 7 月 30 日
From within GUIDE, go into the property inspector for both radio buttons and ensure that the Value field is set to 0.
その他の回答 (2 件)
Salaheddin Hosseinzadeh
2014 年 7 月 30 日
Hi Jihad,
You can disable the one radio button as you clicked the other one.
Hopefully, you remember my previous assumptions and example
so do it like this
function radio_button1_Callback(hObject,eventdata,handles)
if get(handles.radio_button1,'Value')
set(handles.radio_button2,'Value',0)
end
2 件のコメント
Andrew Reibold
2014 年 7 月 30 日
I have used personally used the above method and it should work for you Jihad. Good luck.
Salaheddin Hosseinzadeh
2014 年 7 月 30 日
Hi Jihad!
Seems like we are just leading you to more problems!
There is a radio_bitton1_CreateFCN(hObject,eventdata,handles) function, which you can use to initialize your radio buttons. All you have to do is to go to this CreateFcn or CreateFCN function and type the as such
set(hObject,'Value',1); % if you want it to be seelcted initialy
set(hObject,'Value',0); % if you want it not be selected initially
regards.
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!