Re: Hide tab control pages
Find this with a bit of googling. Might help. You can try something like
Code:
'Hides the second tabpage.
TabControl1.Controls.Remove(TabControl1.TabPages(1))
'Unhide the second tabpage.
TabControl1.Controls.Add(New TabPage("TabPage2"))
Re: Hide tab control pages
Check this out. I just googled "hide tabpage vb.net". The person kinda clears the air about tabcontrols/pages.
Re: Hide tab control pages
Try this
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' hide tab page
TabControl1.TabPages.Remove(TabPage4)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' show tab page
TabControl1.TabPages.Insert(3, TabPage4)
End Sub
Re: Hide tab control pages
Yeah I was thinking the same.
Save the tab your removing, then remove the original tab..
vbnet Code:
Dim tab As TabPage = TabControl1.TabPages(x)
TabControl1.TabPages.Remove(tab)
Then when wanting to show them simply add it back...
vbnet Code:
TabControl1.TabPages.Add(tab)
tab = Nothing
To be quite honest though, I'm not sure of this behavior. It could have some negative effects, such as the controls on that page being removed. But again I'm not 100% sure.
It would be nice though if this was already a feature of the control :p
If it does work, then you could even go as far as implementing this feature into the tab control by inheriting the tab control and internally adding this feature.
Re: Hide tab control pages
Neat (but surprising)--you don't need to save the tabs. What 4x2y suggested will work perfectly.
Re: Hide tab control pages
Ohhhh I see, so the TabPages doesn't actually remove the page? I Was just guessing they both went hand in hand, so if you had removed TabPages(0), then the page containing all the controls that went with that tab would be removed as well.
Learning everyday :)
Re: Hide tab control pages
TabControl is just a container for TabPage, so adding removing TabPage will not touch its controls, and this gives you ability to merge different TabPage from different TabControl.
Re: Hide tab control pages
Quote:
Originally Posted by
4x2y
TabControl is just a container for TabPage, so adding removing TabPage will not touch its controls, and this gives you ability to merge different TabPage from different TabControl.
Hmmm interesting, thanks! Not my post but still helping.
Re: Hide tab control pages
Quote:
Originally Posted by
colleen.boye
Neat (but surprising)--you don't need to save the tabs.
When you drag a control onto your form, it creates you a variable for that control which you are using likely without even knowing it. Everytime you type TextBox2.Text = xxxx, you are accessing a variabled called TextBox2. You define variables like so
Dim MyNumber As Integer
And this is what the designer does for you on the "hidden" designer file. Removing the tabpage from the tabcontrol just means its just not visible anywhere, but you still have a variable to that tabpage, it still exists as do all the controls on it.