Hello sir,
I am having one tabcontrol and many tabpages in it.
I want to activate it with the button control.
so when i click button1, tabpage2 must be shown. and so for button 2 etc.
so i used the code below, but not working.

Tabpage2.show()

Recommended Answers

All 3 Replies

You change the current tab page from the tab control

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    '
    TabControl1.SelectedIndex = 1

End Sub

shows the second tab page.

You change the current tab page from the tab control

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    '
    TabControl1.SelectedIndex = 1

End Sub

shows the second tab page.

Thanks thats working.
After selecting the second tab, can i able to hide other tabs?

There's neither Visible nor Enabled properties in TabPages. But you can prevent user from changing tabpages

Private ShowTabIX As Integer
Private bSetTabIndex As Boolean

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  '
  ShowTabIX = 1
  bSetTabIndex = True
  TabControl1.SelectedIndex = ShowTabIX
  bSetTabIndex = False

End Sub

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
  '
  If Not bSetTabIndex AndAlso TabControl1.SelectedIndex <> ShowTabIX Then
    TabControl1.SelectedIndex = ShowTabIX
  End If

End Sub

However, IMHO you lose a bit of the point of the tab control.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.