Hi,
I have a tabcontrol that has a tabpage, I want to add another tabpage on
runtime, but I want the tabpage to be added to the 1st tab, anyone know how
to do it?
Thanks,
Tee
Ed Kaim - 17 Jan 2005 07:03 GMT
There's probably a better way, but some C# code that seems to work is:
TabPage p = new TabPage("My Tab Page");
this.tabControl1.TabPages.Add(p);
for (int lcv = this.tabControl1.TabPages.Count - 1; lcv > 0; lcv--)
{
this.tabControl1.TabPages[lcv] = this.tabControl1.TabPages[lcv - 1];
}
this.tabControl1.TabPages[0] = p;
> Hi,
>
[quoted text clipped - 5 lines]
> Thanks,
> Tee
Mick Doherty - 17 Jan 2005 10:15 GMT
There's no better way ;-)

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
> There's probably a better way, but some C# code that seems to work is:
> TabPage p = new TabPage("My Tab Page");
[quoted text clipped - 20 lines]
>> Thanks,
>> Tee
Cor Ligthert - 17 Jan 2005 09:33 GMT
Tee,
Because of a bug in the tabpages, you have probably first to "remove" all
the existing ones and than "add" again all the ones in the sequence that you
want them.
Cor
Mick Doherty - 17 Jan 2005 10:13 GMT
> Tee,
>
[quoted text clipped - 3 lines]
>
> Cor
No! Don't remove tabpages as this will cause unsightly flicker. Simply swap
tabpages.
On my site you'll find routines for inserting a tabpage which uses a loop to
swap tabpages until the new tabpage is where you want it.
http://dotnetrix.co.uk/tabcontrols.html --> Hide and show tabpages in
Tabcontrol

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Cor Ligthert - 17 Jan 2005 10:26 GMT
Mick,
Everything can be done better, however to say a screaming "No" to it is in
my opinion overdone.
Not angry, just friendly laughing.
Cor
Mick Doherty - 17 Jan 2005 12:05 GMT
Sorry Cor.
I'd just got up and hadn't had my fix of Coffee yet.

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
> Mick,
>
[quoted text clipped - 4 lines]
>
> Cor