cmdolcet
asked on
A simple way to hide tabs on a tab control
If I use the following code it will hide the tab or display the tab, the only problem is that when it displays the tab no control are present inside the tab. Do the controls need to be added dynamically after the Tabpages.add ? or am I missing something?
If _masterGlobalParameters.masterGlobal.MasterShowDSG_SGProbeTab = True Then
TabControl1.TabPages.Add(TabSGGages)
Else
TabControl1.TabPages.Remove(TabSGGages)
End If
That code isn't hiding/displaying tabs it's removing/adding them and when you add a tab it will be empty, i.e. have no controls.
ASKER
Its been a long night sorry, however is there a property to actually hide or display a certain tab control?
Actually I'm not quite right, when you remove a tab page it isn't destroyed and you can add it back to the tab control again.
For example if you had 2 tabs you could use this to toggle the second tab.
For example if you had 2 tabs you could use this to toggle the second tab.
Dim tb As TabControl
tb = TabControl1
If tb.TabPages.Count = 2 Then
tb.TabPages.Remove(TabPage2)
Else
tb.TabPages.Add(TabPage2)
End If
Note in this code you have to specify the tab page to add/remove, you can't use an index to refer to the tab page, not sure if that'll affect what you are trying to do but it might be a problem.
ASKER
Norie the. count is not a property of the tab control
It's a property of the TabPages collection of the tab control, that's why I used TabPages.Count in the code I posted.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.