フィルターのクリア

How to toggle: Making uicontrols (in)visible

7 ビュー (過去 30 日間)
Hello kity
Hello kity 2012 年 12 月 31 日
Hi
I want to make a couple edit fields and static texts visible and invisible by using a button/toggle button. But how to do that?
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (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 togglebutton1
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
set(handles.Edit1,'Visible','off')
elseif button_state == get(hObject,'Min')
set(Edit1,'Visible','on')
% Toggle button is not pressed-take appropriate action
...
end

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 12 月 31 日
編集済み: Azzi Abdelmalek 2012 年 12 月 31 日
% you've written 'Edit1' instead of 'handles.Edit1'
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
set(handles.Edit1,'Visible','off')
elseif button_state == get(hObject,'Min')
set(handles.Edit1,'Visible','on')
end
  2 件のコメント
Hello kity
Hello kity 2013 年 1 月 2 日
編集済み: Hello kity 2013 年 1 月 2 日
how can i make that edit1 field a NaN if the edit field is not visible?
str2double(get(handles.Edit1,'String'))=NaN;
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 2 日
Why are you using get?
set(handles.Edit1,'string','nan')

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by