how can i hidder(or enable='off') tab2?

11 visualizaciones (últimos 30 días)
piero
piero el 16 de Sept. de 2023
Respondida: Sreeram el 27 de En. de 2025 a las 6:56

Respuestas (1)

Sreeram
Sreeram el 27 de En. de 2025 a las 6:56
Hi Piero,
I understand that you are trying to hide Tab2, and unhide it when certain condition is met.
Currently, the ability to directly enable/disable or unhide/hide a tab in a MATLAB tab app group does not seem to be supported. However, here is a workaround to unhide/hide a tab in a tab group indirectly through code.
1) In the app's start up callback function, set the parent of the second tab to be empty.
app.Tab2.Parent=[];
2) Then, in the callback of each component whose conditions may make the second tab viewable, check each condition to see if the second tab should be enabled. If the conditions are met, reparent the tab to the tab group. Otherwise, keep the second tab's parent property empty.
function ControlValueEditFieldValueChanged(app, event)
value = app.ControlValueEditField.Value;
if(value==1)
app.Tab2.Parent=app.TabGroup;
else
app.Tab2.Parent=[];
end
end
This logic should make the second tab appear and disappear when necessary without changing the properties of all the components in the second tab.
Here is a GIF that shows the behaviour:
An MLAPP file implementing this logic is attached.
I hope this helps!

Categorías

Más información sobre Develop uifigure-Based Apps 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