Link to home
Start Free TrialLog in
Avatar of keymac
keymacFlag for Australia

asked on

Creating Tab control at runtime in VB.Net

I have created a tab control at run time like this

Public Class Form1
    Public sTab As TabControl

Form1_Load
            sTab = New TabControl
            sTab.Name = "Tab" & ix
            sTab.Left = 500
            sTab.Width = 1000

            sTab.TabPages.Add(New TabPage("Page 1"))
            sTab.TabPages.Add(New TabPage("Page 2"))
            sTab.TabPages.Add(New TabPage("Page 3"))

            Me.Controls.Add(sTab)
End Sub

Now I want to select the a tab page not from clicking on it but from another event such as

Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
        sTab.SelectTab(2)
end sub

End Class

Why is this wrong???
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keymac

ASKER

There should be a

For ix = 1 to 4
next

Loop around the creation of the stab code

If you click the button the selected tab does not change
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial