setting the order of TabPages in a TabControl

E

Ed Debrot

I can't seem to make any sense of how to control the order of my TabPages on
a TabControl. I can set the Index property in regular .Net but can't do that
in CF .Net. Does anyone know how to set the order of TabPages at runtime?

Note that I am able to hide pages using RemoveAt.

thanks.
 
E

Ed Debrot

It appears that the only thing that works consistantly in .Net CF is to go
into the Windows generated code and re-order the loading of tabpages,
tc.Controls.Add(tp), in the order that you want them displayed. The code
below works fine in desktop .Net.

thanks for the reply.
 
D

Daniel Moth

Yes it works on the desktop and yes it is a bug.
You can at runtime clear the tabs and re-add them in your preferred order as
I suggested and that works consistently too.

Cheers
Daniel
 
C

Chris Tacke, eMVP

And as soon as you modify the Form, the designer will hose it again. Follow
Daniel's advice and reorder them outside of InitializeComponent in the ctor.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
E

Ed Debrot

I tried his advice and it works fine on the desktop but not in CF .Net. I
also tried several variations and suggestions based on other threads. No
luck. It's true that the designer will hose my tab order but only if I add
more tab pages to the specific tab control in question and I want the added
tab page to be somewhere other than the end. Your concern is noted and I
would agree if I could get it to work as suggested.

thanks.
 
P

Paul G. Tobey [eMVP]

What happens when it "doesn't work"?

Paul T.

Ed Debrot said:
I tried his advice and it works fine on the desktop but not in CF .Net. I
also tried several variations and suggestions based on other threads. No
luck. It's true that the designer will hose my tab order but only if I add
more tab pages to the specific tab control in question and I want the
added
tab page to be somewhere other than the end. Your concern is noted and I
would agree if I could get it to work as suggested.

thanks.
 
D

Daniel Moth

You will lose your changes every time you change anything via the designer.
Step back and look at the big picture. We've all had this problem and we've
all solved it as suggested. Do you really think your case is "special"?

If you need more help, post a small reproducible sample along with a
description of the actual results and the expected results (including what
device you are targeting and framework version).

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top