How do I clone a tab page?

  • Thread starter Thread starter Scott Gunn
  • Start date Start date
S

Scott Gunn

In my app I want to have a run-time generated tab showing various controls -
for instance a form for a user to fill in.

I have a tab page in a hidden tabcontrol and all I want to do is clone it to
another tabcontrol and show it.

Giving me the ability to show maybe 5, 6 , 7 or more of the same tab page.

Any Ideas?
Scott
 
OK,

In my form (form1) I have a hidden tabcontrol where I store my tabpage
(TabPage1), I also have a second tabcontrol (TabControl2).

Now the code:
-----------------------------------------------------------------
Dim frmNewForm as New Form1
Dim NewTab as TabPage = frmNewForm.TabPage1

TabControl.TabPages.Add(NewTab)

NewForm.Dispose()
-----------------------------------------------------------------

Question1:
What do you all think to this method?

Question2:
Does this create a memory leak? Or how can I find this out?

Regards
Scott.
 
Why not Inherit from Tabpage and add instances of that to your Tabcontrol.

Add a new UserControl to your project.
Add the controls you want to see on the Tabpage.
When you are happy with the layout, close the designer and edit the code to
replace:
Inherits System.Windows.Forms.UserControl
with
Inherits System.Windows.Forms.Tabpage

Rebuild the project and your off...
 
Back
Top