How do I change the options in a dropdown menu after a button is pressed in app designer?
24 views (last 30 days)
Show older comments
To keep this short:
I have a dropdown menu with 7 options, and a button. In the buttons callback function I want to be able to remove some of the options to reduce the number of options to say 5.
How can I do this?
0 Comments
Accepted Answer
Jinal
on 16 Mar 2023
Hi Carson,
As per my understanding you wish to use the button you have created to reduce the number of available options in your dropdown menu.
You can do this using the following as the body of your button’s callback function.
app.DropDown.Items = {'Option 1', 'Option 2', 'Option 3','Option 4', 'Option 5'};
If you are using a state button, the callback function’s body would would look like following:
value = app.Button1.Value;
if value == 1
app.DropDown.Items = {'Option 1', 'Option 2', 'Option 3','Option 4', 'Option 5'};
else
app.DropDown.Items = {''Option 1', 'Option 2', 'Option 3','Option 4', 'Option 5', Option 6', 'Option 7'};
end
Hope this helps.
0 Comments
More Answers (0)
See Also
Categories
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!