필터 지우기
필터 지우기

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

조회 수: 22 (최근 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