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

11 views (last 30 days)
piero
piero on 16 Sep 2023
Answered: Sreeram on 27 Jan 2025 at 6:56

Answers (1)

Sreeram
Sreeram on 27 Jan 2025 at 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!

Categories

Find more on Develop uifigure-Based Apps 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!