How to add tabpage to tabcontrol at 1st tab?

How to add tabpage to tabcontrol at 1st tab?

Post by Tee » Tue, 18 Jan 2005 11:05:42


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
 
 
 

How to add tabpage to tabcontrol at 1st tab?

Post by Ed Kai » Tue, 18 Jan 2005 16:03:58

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;

 
 
 

How to add tabpage to tabcontrol at 1st tab?

Post by Cor Ligthe » Tue, 18 Jan 2005 18:33:01

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
 
 
 

How to add tabpage to tabcontrol at 1st tab?

Post by Mick Doher » Tue, 18 Jan 2005 19:13:50


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://www.yqcomputer.com/ ; Hide and show tabpages in
Tabcontrol

--
Mick Doherty
http://www.yqcomputer.com/
 
 
 

How to add tabpage to tabcontrol at 1st tab?

Post by Mick Doher » Tue, 18 Jan 2005 19:15:51

There's no better way ;-)

--
Mick Doherty
http://www.yqcomputer.com/
 
 
 

How to add tabpage to tabcontrol at 1st tab?

Post by Cor Ligthe » Tue, 18 Jan 2005 19:26:50

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
 
 
 

How to add tabpage to tabcontrol at 1st tab?

Post by Mick Doher » Tue, 18 Jan 2005 21:05:03

Sorry Cor.
I'd just got up and hadn't had my fix of Coffee yet.

--
Mick Doherty
http://www.yqcomputer.com/