(App Designer) set the dropdown with variable

조회 수: 232 (최근 30일)
Yu Li
Yu Li 2018년 4월 2일
답변: Prasanth Sunkara 2018년 4월 10일
I'm new to Matlab App Designer. I created a drop down buttom and want to set it with desired string variables.
I set like below picture but after run the app, the variables were not appeared in the drop down selections.
is there any mistake with my operation?
Thanks

답변 (1개)

Prasanth Sunkara
Prasanth Sunkara 2018년 4월 10일
The reason for this behavior is that the values are set in the DropDownValueChanged instead of startupFcn.
If your intention is to initialize the values of the drop-down programmatically, you need to do that in ' startupFcn ' callback.
Alternatively, you can initialize the UI values directly from UI configuration parameters of the 'Design View'. However, I would personally recommend using the 'startupFcn' approach.
A quick tip: Why are you creating a new dropdown UI (check your 2 and 3 line numbers of your code) instead of updating the values?
Consider using the below approach.
function startupFcn(app)
value = app.DropDown.Value;
app.DropDown.Items = {'Red','Blue'};
end
Thanks, Prasanth

카테고리

Help CenterFile 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!

Translated by