Me.TabControl1.SelectedIndex=2 ' Switch to the third tab
' Do stuff
Me.TabControl1.SelectedIndex=0 ' Back to the first tab
' More sttuffDetecting when a tab page is beeing activated:
The Selected event on the control itsself is begin triggered when a tab change is done.
Private Sub TabControl1_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Selected
Msgbox("Tab changed")
End Sub
Detecting which tab is active (combined with the above tabchange event)
Private Sub TabControl1_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Selected
msgbox(TabControl1.SelectedIndex & " is active")
End Sub
It is also possible to reference tab controls by name, instead of tab number. The example below demonstrates how to hide a tab page from a tabcontrol with a name reference
' --- Hide the tab named DemoTab
TabControl1.Controls.Remove(TabControl1.TabPages("DemoTab"))
' --- And show it again
TabControl1.Controls.Add(New
TabPage("DemoTab"))