By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

TabControl question.

P: n/a
Gav
I am writing an application where I will have a TabControl and 3 styles of
Tabs to go in it, each containing different controls. The tabs will be added
to the tabcontrol when items are clicked on in a TreeView. So the the
application starts by displaying no tabs and adds them in as required. There
could be any number of each tab (0 upwards).

What is the best way of me doing this? Should I create 3 custom controls
that extend TabPage? I've only been doing this for a couple of days so any
advice would be great.

thanks

Gav
Sep 13 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

"Gav" <ga*@nospam.comwrote in message
news:ep**************@TK2MSFTNGP02.phx.gbl...
>I am writing an application where I will have a TabControl and 3 styles of
Tabs to go in it, each containing different controls. The tabs will be
added to the tabcontrol when items are clicked on in a TreeView. So the the
application starts by displaying no tabs and adds them in as required.
There could be any number of each tab (0 upwards).

What is the best way of me doing this? Should I create 3 custom controls
that extend TabPage? I've only been doing this for a couple of days so any
advice would be great.
When you are designint it just create your TabPages inside the tabcontrol,
when you are done you remove the part of the code when those pages are added
to the tabcontrol. Finally you can add/remove then using code:

tabControl.TabPages.Remove( tabPage1);
tabControl.TabPages.Add( tabPage2);
tabPageXXX will be created by the designer and will be member of the class.

If you want to do this dynamically you can do a similar approach but just
creating the pages as you need, In this case you just cut the code generated
by the designer.
Sep 13 '07 #2

P: n/a
On 13 Sep, 16:09, "Gav" <g...@nospam.comwrote:
I am writing an application where I will have a TabControl and 3 styles of
Tabs to go in it, each containing different controls. The tabs will be added
to the tabcontrol when items are clicked on in a TreeView. So the the
application starts by displaying no tabs and adds them in as required. There
could be any number of each tab (0 upwards).

What is the best way of me doing this? Should I create 3 custom controls
that extend TabPage? I've only been doing this for a couple of days so any
advice would be great.

thanks

Gav
I'm not sure I fully understand what you want to do, but I can give
you an idea, and you'll decide if it fits for you.
I would create in designed a single TabControl containing ALL
possibile TabPages.
In form's constructor, right after calling InitializeComponent(), I
would initialize 3 arrays of TabPages. You must declare the array as
members of your form's class. Each array containg the combination of
TabPages that should be displayed when items are clicked in TreeView
control. I would set the Tag property of each TreeNode to the
corresponding array. This will help you later.

After initializing the arrays, you may clear all TabPages, so
initially, you have an empty TabControl.
When a TreeNode is selected, you just need to:
1. clear the TabPages in TabControl.
2. get the list of TabPages using TreeNode's Tag property and add the
pages to the TreeControl.

I didn't try this, but I don't see any reason it shouldn't work...
Hope it helps.

Sep 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.