How do I change the options in a dropdown menu after a button is pressed in app designer?

11 次查看(过去 30 天)
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?

采纳的回答

Jinal
Jinal 2023-3-16
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
You can refer to this page for more information about creating callbacks.
Hope this helps.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by