how can i hidder(or enable='off') tab2?
11 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1484242/image.png)
2 Comments
Walter Roberson
on 16 Sep 2023
One method, even if it isn't all that nice: https://www.mathworks.com/matlabcentral/answers/345592-how-can-i-disable-tab-switching-for-a-uitabgroup#answer_271354
Answers (1)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1824286/image.gif)
An MLAPP file implementing this logic is attached.
I hope this helps!
0 Comments
See Also
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!