How do I clone a tab page?

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
 
S

Scott Gunn

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.
 
M

Mick Doherty

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top