To hide a TabPage control, you have to simply remove it from the
TabControl's TabPages collection property. This is the only
known way to hide a TabPage from a TabControl:
// removes the first TabPage object in the TabPages collection:
this.tabControl1.TabPages.Remove(this.tabPage1);
You normally won't have to worry about losing the TabPage control
*if* it was created at the class level (rather than in a property or method).
An effective way to hide and restore Windows Tabpages is by using collection object.
If you are using VB.NET 2005 then the following example will do easy.
***** Create a private object collection ******
Private _TabPages As New System.Collections.Generic.List(Of TabPage)
'NOTE: This collection object ensure that the type of object to store is a TabPage.
********* to the event that remove the tabpage or tabpages *****
Sub MyRemoveEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyRemoveEvent.Click
Dim oPage As TabPage = Nothing
_TabPages.Clear() ' Clear any objects it may have previously. This is true if you reuse this object.
For Each oPage In TabControl2.TabPages
_TabPages.Add(oPage) 'here you are storing the object into the collection
TabControl2.TabPages.Remove(oPage) ' here you are deleting the object from the TabControl
Next
TabControl2.Refresh() ' just a refresh. no need to but I like it.
End Sub
'****** Ok Now the event which put them back into the TabControl ********
Sub MyRestoreEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyRestoreEvent.Click
Dim oPage As TabPage = Nothing
For Each oPage In _TabPages
TabControl2.TabPages.Add(oPage)