Multiple dropdown inputs to narrow down file options in App Designer
25 次查看(过去 30 天)
显示 更早的评论
Good morning!
I have been using MATLAB App Designer for two months or so and right now, I am having some troubles using drop downs.
My goal is to have the user choosing 3 different values in 3 different drop downs. By choosing the first value in the first drop down, depending on the available options in the database, the values will adapt in the second drop down and then the user will pick a second value. After the first two values are chosen, the values in the third drop down will adjust again so that the user can choose the value needed. Once the three values are chosen, a different drop down menu otside of this panel will display the files that matches the values chosen by the user so that its data can be uploaded and the data plotted.
Would it be something possible?
Thank you!
采纳的回答
Jon
2023-7-27
编辑:Jon
2023-7-27
I have attached a very simple example of how you might have the choice from one drop down menu change the possible choices from a second drop down. In this example initially both drop downs have three items. The first has Choice A, Choice B, Choice C, the second has Choice 1, Choice 2, Choice 3. When you select an item from the first list, the corresponding element is eliminated from the second list. So if you pick Choice B from the first list, the second drop down becomes Choice 1, Choice 3 (Choice 2 is eliminated). Anyhow this is just to illustrate the principle. You can modify with your specific logic.
The key idea is to use the value changed callback from the first drop down, to modify the Items property of the second,
% Code that executes after component creation
function startupFcn(app)
% Define initial drop down item lists
app.DropDown1.Items = {'Choice A','Choice B','Choice C'};
app.DropDown2.Items = {'Choice 1','Choice 2','Choice 3'};
end
% Value changed function: DropDown1
function DropDown1ValueChanged(app, event)
value = app.DropDown1.Value;
% Modify second drop down menu according to choice made here,
% specifically eliminate corresponding drop down item in the
% second list
idx = find(ismember(app.DropDown1.Items,value));
app.DropDown2.Items(idx) = [];
end
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!