Populate one pop up menu on the basis of selection in another pop up menu.
1 次查看(过去 30 天)
显示 更早的评论
Hello
I have two popup menus. popup menu1 : Directory and popup menu2: File names. In pop up menu 1 directory names should appear and in popup menu 2 Files in that directory should appear.
However, when I click any of the directory names in popup menu 1 then only the file names in first directory are being displayed. Please help me.
for i = 1 : size(dirinfo,1)
%Reading names of People
People(i).Name = dirinfo(i,1).name;
text{i}= People(i).Name;
%Reading files of all people in structure format
cd(Functions_Dir)
People(i).Image_Name = ReadFileNames([Home_Dir '\Inputs\' dirinfo(i,1).name]);
text1{i}= People(i).Image_Name ;
cd ..
end
set(handles.popupmenu1,'string',text);
a=get(handles.popupmenu1,'value');
switch a
case 1
tex= text1{1};
case 2
tex= text1{2};
end
set(handles.popupmenu2,'string',tex);
0 个评论
回答(1 个)
ES
2017-3-22
In call back of popupmenu1 you should write this..
a=get(handles.popupmenu1,'value');
switch a
case 1
tex= text1{1};
case 2
tex= text1{2};
end
set(handles.popupmenu2,'string',tex);
is this done? I am not able to see the functions in your code. That is why I am clarifying.
7 个评论
Jan
2017-3-22
@Sidra: It is not easy to guess, what exactly "the first directory" is. Remember that I do not have the faintest idea about what you are doing.
I assume the problem appears at the location, where you define, what the "first" and "second" directory is. Where does this happen?
Do you know how to step through the code using the debugger?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!