468,469 Members | 2,291 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,469 developers. It's quick & easy.

Create TabPages at runtime (with controls)

Luc
Hi,

I have a TabControl and, at runtime, I need to add some tabpages. The
problem is that each tabpage is similar to the others and contains several
controls.

If I do TabControl.TabPages.Add(MyTabPage), a new BLANK tabpage is added.
How can I add in few statements a new tabpage as well as its controls
(textboxes, labels, etc.)? The first tabpage (that I create at design time)
is the "template" to be used for the other tabpages. Is there a way at
runtime to duplicate the first tabpage and create new tabpages based on this
one (including controls)? Also: how can I reference (at runtime) the newly
created tabpages and their controls?

Thanks,

Luc

Nov 20 '05 #1
1 2495
"Luc" <no****@nospam.com> schrieb

I have a TabControl and, at runtime, I need to add some tabpages.
The problem is that each tabpage is similar to the others and
contains several controls.

If I do TabControl.TabPages.Add(MyTabPage), a new BLANK tabpage is
added. How can I add in few statements a new tabpage as well as its
controls (textboxes, labels, etc.)? The first tabpage (that I create
at design time) is the "template" to be used for the other tabpages.
Is there a way at runtime to duplicate the first tabpage and create
new tabpages based on this one (including controls)? Also: how can I
reference (at runtime) the newly created tabpages and their
controls?


You could create a Usercontrol and put it on the first TabPage. Then, at
runtime, create new instances of the Tabpage and the Usercontrol.

Or, derive your own class from the Tabpage class, but you won't be able to
use a designer to design it.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by wpy | last post: by
2 posts views Thread by Scott Kelley | last post: by
4 posts views Thread by Rainer Queck | last post: by
7 posts views Thread by =?Utf-8?B?YW5kZXJzY2g=?= | last post: by
1 post views Thread by kollasaeta | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.