Re: TabControl question.

Tech-Archive recommends: Fix windows errors by optimizing your registry



On 13 Sep, 16:09, "Gav" <g...@xxxxxxxxxx> wrote:
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.

.



Relevant Pages

  • Re: tab control bug?
    ... See an article I wrote in May 2004 about the TabControl from ... The bug that is the most irritating is probably the fact that the TabPages ... Collection editor (in design mode) I reordered the tabs using the up/down ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: auf welchen tab im TabControl wurde geklickt?
    ... Das Problem ist erstens, dass Mouseeventargs e.Location die relative Mausposition auf dem TabControl ist, es muss also noch die Position des TabControls addiert werden, dann liefert die Funktion aber leider nur das TabControl selbst und keine TabPage. ... Ich dividiere Mouseeventargs e.X durch TabControl tc.ItemSize.Width und erhalte damit eine Integerzahl, die dem Index des Tabs entspricht. ... Somit kann man also den falschen Index erwischen oder sogar eine Zahl ausserhalb der Anzahl der TabPages. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • tabcontrol & menu (newbie question)
    ... I have used VS2003 to make a pocket PC application. ... and I simply had a tabcontrol with four ... Now, however, as the application is more complex, I have 7 tabpages. ... I didn't like the tabs at the bottom anymore, ...
    (microsoft.public.pocketpc.developer)
  • How to Set Colors on TabPage?
    ... a TabControl with 4 tabs. ... I have changed the backcolor of the form and now trying to change the backcolor of all the TabPages (not tabs). ...
    (microsoft.public.access.modulesdaovba)
  • Re: Sharing a component across multiple tabs
    ... how about making a tab control that is only as tall as the tabs themselves.. ... I have to use the TabControl - our users expect it as a result ... TabControl next to the data panel, but make it look as if it is the ...
    (microsoft.public.dotnet.framework.windowsforms)