Copying Tab pages

G

Guest

I want to add additional tab pages on my form e.g.

Dim db As New TabPage
tabDetails.Controls.Add(db)

Where tabDetails is the tabcontrol on the form.

What is the best way of ensuring that all of the controls (e.g. textboxes,
combo boxes etc) from the first tab page get copied onto any new tabpages I
create ?

Thanks
 
C

Cor Ligthert

DotNetNewbie,
What is the best way of ensuring that all of the controls (e.g. textboxes,
combo boxes etc) from the first tab page get copied onto any new tabpages
I
create ?

Your question has a simple answer. That is where usercontrols are build for.

I hope this helps,

Cor
 
G

Guest

no.

I know I could do a sweep of all controls on the tabpage and add them

Dim obj As Object

For Each obj In tbMain.Controls
'add the control to tabpage here
Next obj

But I'm really asking is there a quicker/better/recommended way of having
the controls from one tabpage onto the new one just created thus:

Dim db As New TabPage
tabDetails.Controls.Add(db) 'none of the existing controls get
copied yet....

???

Thanks
 
H

Herfried K. Wagner [MVP]

dotnetnewbie said:
I want to add additional tab pages on my form e.g.

Dim db As New TabPage
tabDetails.Controls.Add(db)

Where tabDetails is the tabcontrol on the form.

What is the best way of ensuring that all of the controls (e.g. textboxes,
combo boxes etc) from the first tab page get copied onto any new tabpages
I
create ?

What you can do is designing a usercontrol that contains all the tabpage's
controls. This control can be instantiated at runtime and added to another
tabpage. However, notice that this won't automatically copy
values/selections made in an existing instance of the usercontrol to the new
instance.
 
G

Guest

I understand now - thanks Cor

Cor Ligthert said:
DotNetNewbie,


Your question has a simple answer. That is where usercontrols are build for.

I hope this helps,

Cor
 

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