UIPanel Changes Content Automatically

1 回表示 (過去 30 日間)
Nasiha Husni
Nasiha Husni 2016 年 6 月 30 日
コメント済み: Samuel Vergara 2016 年 7 月 2 日
Hi good evening,
I want make the content changes at Uipanel once user selected at popupmenu bar.
in here I set the code but how to make it changes according to user selected, the previous content will replace with new content at popupmenu selected: i'm using switch case for selected
contents = get(hObject,'String');
selected = get(hObject,'Value');
item_selected = contents{selected};
display(item_selected);
switch contents{selected};
case'Method 1'
set(handles.edit25,'visible','on');
set(handles.edit26,'visible','on');
set(handles.popupmenu18,'visible','on');
case'Method 2'
disp(handles.text25,'String','Hello')
like when user select method 1 at classification, the content in method 1 will show at "Result(uipanel)" space, and when user select method 2 at classification, the content in method 2 will show and content at method 1 will dissapear.
pls give me how to set the code to show it, I already try Visible "off" but its not working
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 6 月 30 日
disp(handles.text25,'String','Hello')
should be
set(handles.text25,'String','Hello')

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

回答 (1 件)

Samuel Vergara
Samuel Vergara 2016 年 6 月 30 日
Is your code in the appropiate callback? I think that in switch you should have the "selected variable", cause it should have the string selected, not an index. so..
selected = get(hObject,'Value');
switch selected,
case'Method 1'
set(handles.edit25,'visible','on');
set(handles.edit26,'visible','on');
set(handles.popupmenu18,'visible','on');
case'Method 2'
disp(handles.text25,'String','Hello');
end
Regards,
  3 件のコメント
Nasiha Husni
Nasiha Husni 2016 年 7 月 1 日
ya..its my code at appropriate callback.
Samuel Vergara
Samuel Vergara 2016 年 7 月 2 日
Check that you are accesing fine to the two switch condition2. If not, maybe you have one or more blank space after 'Method 1' or 'Method 2'. If it's ok, try to add a "drawnow" command.
I hope this helps, regards

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

カテゴリ

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