0

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()
2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Teme64
0

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.

0

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?

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.