Private Function HideTabPage(ByVal tc As TabControl, _
ByVal tp As TabPage) As Boolean
If tc.TabPages.Contains(tp) Then
tc.TabPages.Remove(tp)
Return True
End If
End Function
Private Function ShowTabPage(ByVal tc As TabControl, _
ByVal tp As TabPage, _
Optional ByVal Index As Integer = -1) As
Boolean
If Not tc.TabPages.Contains(tp) Then
If Index > -1 Then
Dim tpc(tc.TabCount) As TabPage
Dim i As Integer
'Starting at our Insert Position, store and remove all the tabpages.
For i = Index To tc.TabCount - 1
tpc(i) = tc.TabPages(Index)
tc.TabPages.Remove(tc.TabPages(Index))
Next
'add the tabpage to be inserted.
tc.TabPages.Add(tp)
'then re-add the original tabpages.
For i = Index To UBound(tpc) - 1
tc.TabPages.Add(tpc(i))
Next
tpc = Nothing
Return True
Else
tc.TabPages.Add(tp)
Return True
End If
End If
End Function
You would then use HideTabPage(TabControl1, TabPage1) to Hide TabPage1 in
TabControl1, and ShowTabPage(TabControl1, TabPage1, 0) to show TabPage1 in
TabControl1 at position 0.
or Download a control from http://www.dotnetmagic.com/