New TabPage

liam

Member
Joined
Jun 8, 2004
Messages
23
Programming Experience
Beginner
I'm creating a program where I need to create new tabpages containing the controls of a pre-designed tabpage and I can't figure out what to do.

1) I can already make new instances of a tabpage using this command...
Private Sub btnNewProvider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewProvider.Click

If Me.TabControl2.TabPages(0).Text = "" Then

Me.TabControl2.TabPages.Add(New TabPage(cbProvider.Text))

End If

End Sub

The problem here now is how can I create a new tab with the same controls as the previous one I designed?

Thanks in advance for your help. God speed:)


 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
You can subClass the TabPage and add the controls. To start, add a new UserControl to your project, add the controls and position them as you like, then change the inherits statement from 'Inherits System.Windows.Forms.UserControl' to 'Inherits System.Windows.Forms.TabPage'. Now use the code you have above and instead of creating a new TabPage, create a new instance of your subClassed TabPage.
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
or try this one:
VB.NET:
 dim num as integer
 'put this in your btnNewProvider_click events
  TabControl1.TabPages.Add(New TabPage("untitled " & (num).ToString()))
  num += 1
hope this helps.
 
Top Bottom