Go to Tab Page

daPoet

Member
Joined
Jul 22, 2008
Messages
23
Programming Experience
Beginner
I'd like to display the content of a particular tab page, when I click on a button

Current my code is
VB.NET:
Me.TabPage1.Show()

That works partially, in that it does display the content of the page, but the correct tab is not selected.

E.g.

If i were on Tab Page 2 and I used this code to show Tab Page 1,

I would see the contents of Tab Page 1 but Tab Page 2 would still be selected.

Please assist.
PHP:
 
You change the SelectedIndex property for the TabControl e.g.

VB.NET:
      TabControl1.SelectedIndex = 1

You can also 'lock' the user onto a specific TabPage by using the Deselecting event e.g.

VB.NET:
    Private Sub TabControl1_Deselecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Deselecting
        Select Case TabControl1.SelectedIndex
            Case 0
                If btnProceed0.Enabled = False Then e.Cancel = True
            Case 1
                If btnProceed1.Enabled = False Then e.Cancel = True
            Case 2
                If btnProceed2.Enabled = False Then e.Cancel = True
        End Select
    End Sub

Hope that helps :D
 
Back
Top