adding many tabs in a single button

dualshock03

Well-known member
Joined
Jan 28, 2007
Messages
105
Programming Experience
1-3
Hi folks.. i need an answer or sample in adding tabpages.. my app has tabcontrol with 10 tabpages with it.. i use to hide them at runtime then show the 1st tabpage by default..

Now, i have a button which corresponds with adding the remaining 9 hidden tabpages.

What i want is, i want to make my button add the 2nd tabpage when i click it, then add again the 3rd tabpage when i choose to click again, and so forth.. up to the last tabpage..

Can anyone help me? tnx and more power!!
 
VB.NET:
Private tabPages As New Stack(Of TabPage)

Private Sub Form1_Load(ByVal sender As Object, _
                       ByVal e As EventArgs) Handles MyBase.Load
    'Remove all but the first page and stack them.
    For index As Integer = Me.TabControl1.TabPages.Count - 1 To 1 Step -1
        Me.tabPages.Push(Me.TabControl1.TabPages(index))
        Me.TabControl1.TabPages.RemoveAt(index)
    Next index
End Sub

Private Sub Button1_Click(ByVal sender As Object, _
                          ByVal e As EventArgs) Handles Button1.Click
    If Me.tabPages.Count > 0 Then
        'Add the page at the top of the stack.
        Me.TabControl1.TabPages.Add(Me.tabPages.Pop())
    End If
End Sub
 
Back
Top