Radio Button and Panel GUIDE

What code should i write under a callback of the radio button when you want to click a radio button, the visibility of the panel is being controlled. Radio button clicked, Panel appears. Radio Button unclick, panel hides...what do you think? Thank you everyone

1 件のコメント

Melvin
Melvin 2012 年 2 月 24 日
the panel---i mean a panel you created on a gui...so only two objects are present on the gui. The radio button and a panel...thank you

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

回答 (1 件)

G A
G A 2012 年 2 月 24 日

0 投票

if (get(hObject,'Value') == get(hObject,'Max'))
set (handles.my_uipanel,'Visible','on');
else
set (handles.my_uipanel,'Visible','off');
end

8 件のコメント

Melvin
Melvin 2012 年 2 月 24 日
i tried this but still it doesn't work, what do you think is wrong? or am i missing something else?
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
if get(hObject,'Value')
set (handles.panelgen,'Visible','on');
else
set (handles.panelgen,'Visible','off');
end
Melvin
Melvin 2012 年 2 月 24 日
but it worked when i used a checkbox instead of a radiobutton...does the button group caused my problem? since i used a button group for my radiobutton...
G A
G A 2012 年 2 月 24 日
may be you have to use this line:
if (get(hObject,'Value') == get(hObject,'Max'))
"Radio buttons set Value to Max when they are on (when selected) and Min when off (not selected)."
http://www.mathworks.co.uk/help/techdoc/creating_guis/f16-999044.html#f16-1003665
Melvin
Melvin 2012 年 2 月 24 日
i used this, and it worked...
function uipanel5_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel5
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'radiogen'
% Code for when radiobutton1 is selected
set (handles.panelgen,'Visible','on');
set (handles.panelmot,'Visible','off');
case 'radiomot'
% Code for when radiobutton2 is selected.
set (handles.panelmot,'Visible','on');
set (handles.panelgen,'Visible','off');
otherwise
% Code for when there is no match.
end
G A
G A 2012 年 2 月 24 日
I have edited the code above
Melvin
Melvin 2012 年 2 月 25 日
what changes have you made?
G A
G A 2012 年 2 月 27 日
Instead of checking for Value 1 or 0 (true or false), for radio button you have to check for Value 'Max' or 'Min'
asma arafat
asma arafat 2017 年 5 月 16 日
hello, i want to show panel with some texts when i click push button only and hide it when i am not click it. any help? thanks

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

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2012 年 2 月 24 日

コメント済み:

2017 年 5 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by