Tab Control Problems

Arkayn

New member
Joined
Oct 28, 2008
Messages
2
Programming Experience
Beginner
Hello, I am trying to create a button in my vb form that when clicked will add a tab control to my form. The code is working, but if I click the button again, it adds another duplicate tab to the end. I only want to have one tab page added, no matter how many times the control is pressed.

This tab was previously hidden and I'm only showing it when the button is pressed. My code is:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TabControl1.TabPages.Remove(TabPage11)
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
TabControl1.TabPages.Add(TabPage11)
End Sub


Can anyone point me in the right direction to get this button to only show 1 copy of the hidden tab page?
 
Try this :rolleyes:
VB.NET:
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        If TabControl1.TabCount < 1 Then
            TabControl1.TabPages.Add(TabPage11)
        End If
End Sub
 
Thank you for the assistance Smiles. I entered the code and now when I press my button, the page does not display at all. A friend from work said that the reason my code is not working is due to my first line of code for the form, as soon as my button code is executed, it reloads the form and hides the tab again. Is there a way to keep my form from executing my original hide statement after it has been executed the first time?
 
Back
Top