Copying Tab pages

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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.
 
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
 
Back
Top