Create a UI Component when Checkbox is checked, remove when unchecked

9 次查看(过去 30 天)
Hello,
I am trying to create a GUI in the App Designer and I want to have it so that when the user presses the checkbox component a new listbox component will be created on screen with further options for the user to interact with. If the user were to uncheck the box I would have the UI created disappear. I have tried to no avail and have not been able to find anything else online helping with this.
Any help is much appreciated!
  2 个评论
Walter Roberson
Walter Roberson 2021-5-11
Is it necessary to create it dynamically? Or would it be acceptable to instead create it statically and only make it visible when it is needed?
Jadon Latta
Jadon Latta 2021-5-11
@Walter Roberson I was actually just about to come and delete the post because I found the visible/invisible attributes and then rewrote what I had to implement that instead and that is working great. Thank you so much for the help though :)

请先登录,再进行评论。

采纳的回答

Jadon Latta
Jadon Latta 2021-5-11
Creating dynamically isn't necessary in my situation and this can instead be solved by simply toggling the visibility of the components. By unchecking the visibilty option within the component attributes and then implementing this code block
% Value changed function: ExtraMilestoneRequirementsCheckBox
function ExtraMilestoneBoxChecked(app, event)
value = app.ExtraMilestoneRequirementsCheckBox.Value;
if value == 1
app.PhasesWithMilestoneRequirementsLabel.Visible = 'on';
app.PhasesWithMilestoneRequirementsListBox.Visible = 'on';
end
if value == 0
app.PhasesWithMilestoneRequirementsLabel.Visible = 'off';
app.PhasesWithMilestoneRequirementsListBox.Visible = 'off';
end
end
into the callback for my checkbox I was able to have the listbox toggle visibility based on the button results.
I will leave the OP up with this answer to help anyone in the future who attempts to follow the same logic as I did and ends up googling how to create a GUI component on button press haha.

更多回答(0 个)

类别

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