App designer drop down

2 views (last 30 days)
Eun Young Park
Eun Young Park on 3 Aug 2018
Answered: Aditya on 20 Jan 2025
I have this drop down in my app, and I want to activate the thickness box as I choose 'nofl' drop down. For example, if I choose '1' in drop down, I wish I could activate 'Structure' thickness box. If I choose '2' in drop down, I wish I could activate 'Structure' & 'Layer 1' thickness box, and not other thickness boxes.
Help me please. I don't know anything about coding.
Also, I have the Matlab script. Is there a easy way to convert this code to App designer? Thankyou.

Answers (1)

Aditya
Aditya on 20 Jan 2025
Hi Eun Young Park,
To activate the thickness boxes based on dropdown selection in MATLAB App Designer, use the "ValueChanged" callback of the dropdown to enable the relevant "EditField" components. Implement logic in the callback to toggle the Enable property of each thickness box.
Here's a sample code snippet for the callback:
% Callback function for DropDown
function DropDownValueChanged(app, event)
value = app.DropDown.Value;
% Reset all EditFields to be disabled initially
app.StructureEditField.Enable = 'off';
app.Layer1EditField.Enable = 'off';
% Add more lines for additional layers if needed
% Enable EditFields based on dropdown selection
switch value
case '1'
app.StructureEditField.Enable = 'on';
case '2'
app.StructureEditField.Enable = 'on';
app.Layer1EditField.Enable = 'on';
% Add more cases for additional dropdown options if needed
end
end
To convert your MATLAB script to App Designer, identify user input and output sections in your script, create corresponding UI components in App Designer, and move the logic into callback functions.
Refer to this documentation to read more about callbacks in app designer:

Categories

Find more on Develop Apps Using App Designer 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!