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

9 visualizaciones (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 11 de Mayo de 2021
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 el 11 de Mayo de 2021
@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 :)

Iniciar sesión para comentar.

Respuesta aceptada

Jadon Latta
Jadon Latta el 11 de Mayo de 2021
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.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by