GUIDE: Updating table rows depending on popup user choice

조회 수: 2 (최근 30일)
Lorenzo
Lorenzo 2013년 6월 26일
Dear all; this is the first time I'm using guide so this may be a really stupid question, sorry about that!
I have a popup and a table. Depending on what's the user choice in the popup, the RowName properties for the table changes. Once I'll have managed this one, then I need to add a second set of table+ popup and do exactly the same thing.
How would you accomplish that? I'm having troubles with this especially because of the nested functions I guess....
Thanks everybody!

채택된 답변

Tom
Tom 2013년 6월 26일
Set this for the popupmenu callback.
In the CreateFcn callback of the popupmenu, you can add some options, e.g.
set(hObject,'String',{'Option 1','Option 2'})
In the Callback of the popupmenu you can then change the table's row names based on the popupmenu selection:
val = get(hObject,'Value');
if val == 1
set(handles.uitable1,'RowName',{'One','Two','Three'})
elseif val == 2
set(handles.uitable1,'RowName',{'Alpha','Beta','Gamma'})
end

추가 답변 (2개)

Lorenzo
Lorenzo 2013년 6월 26일
Great! It works perfectly! I've been fighting with this for the whole day... I guess my problem is that when I built the user interface I edited some stuff by end in the GUI itself (for instance I entered the Option 1','Option 2' you mentioned above in the property editor of the popup menu rather than entering them in the matlab editor) this way I could not change anything from the editor itself... So, to solve this, I had to start everything from scratch again.... Is it supposed to work this way?
Thanks again for your help!
  댓글 수: 1
Tom
Tom 2013년 6월 26일
You can do either - I prefer to edit in the script because I find it easier to see what I've set, and it's easier to change, but that's a personal preference.

댓글을 달려면 로그인하십시오.


Lorenzo
Lorenzo 2013년 6월 27일
Dear all; I need to create more than one popup+list set so it would be good if I could use a variable for the options for the popup and some variables for the RowName option for the lists. Now, I created a variable and I defined that as global but it doesn't seem to be passed to the subfunctions of the popup and the list. So: 1- what's the right way to define this variable? Handle, glabal.... 2- where do I have to define this variable? I tried defining it inside the _OpeningFcn and the _OutputFcn with no luck.
Thanks again!
  댓글 수: 1
Lorenzo
Lorenzo 2013년 6월 27일
Ok, I solved it by declaring my lists as variables in the OpeningFcn, and by declaring them as global. Previously I forgot to declare them as global also within the function where I needed to use them, that's why I could get them to work properly.
Sorry for the silly question...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by