Borrar filtros
Borrar filtros

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

22 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by