Help on Disappearing Popupmenu
Show older comments
So I've created a GUI with a popupmenu, but it seems that whenever I try to populate the menu, it disappears, anyone know what going on. Thanks in advance. Heres an example of what I am trying to do.
var1 = {'Ex1','Ex2','Ex3'}
for i =1:length(var1)
set(handles.popupmenu1,'String',var1(i),'Value',i)
end
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 14 Jul 2014
Edited: Azzi Abdelmalek
on 14 Jul 2014
Why the for loop?
var1 = {'Ex1','Ex2','Ex3'}
i=1
set(handles.popupmenu1,'String',var1,'Value',i)
4 Comments
Franco
on 14 Jul 2014
Azzi Abdelmalek
on 14 Jul 2014
There is something in your code that causes this problem, but not the lines of code you've posted
Franco
on 14 Jul 2014
Image Analyst
on 14 Jul 2014
Azzi's code is correct. If it doesn't work, then do it in two separate steps, set the string first, and then the value. Do not use a for loop. The items are not entered in one at a time like you tried, they are done all at once with a single call to set the string property.
Categories
Find more on Startup and Shutdown 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!