GUIDE: Updating table rows depending on popup user choice

2 views (last 30 days)
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!

Accepted Answer

Tom on 26 Jun 2013
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
elseif val == 2

More Answers (2)

Lorenzo on 26 Jun 2013
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 Comment
Tom on 26 Jun 2013
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.

Sign in to comment.

Lorenzo on 27 Jun 2013
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 Comment
Lorenzo on 27 Jun 2013
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...

Sign in to comment.


Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!