Another tabcontrol odditiy

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

I have 11 tabs that I assign at design-time. Yet their index order seems to
change randomly during run-time, making it impossible to remove tabs that do
not apply for a particular usage. For example, the "Plan" tab is index 9 at
design-time, but during run-time, it might load as 7 or whatever. What do I
not know here?
 
Earl,

I've also had this happen. Here's what's going on: you add your
11 tabs to the tabcontrol at design time. Entries for each tab page are
added to the Forms Designer code in the InitializeComponent method
that respect the tabpage indexes you effectively set using the visual
designer.

Occasionally, with enough builds followed by changes to the form or
tabcontrol,
the .resx file associated with the form seems to get confused and the
indexes on the
tab pages change, in the code! To fix this, just open the Forms Designer
generated code
you aren't supposed to be editing and manually set the indexes of your tab
pages
to the order you desire them to appear.

I have never seen a difference between what's actually in the code and the
tabpage ordering
that results at runtime (as one would expect).

-Darren Shaffer
 
Excellent Darren. I had looked at the forms designer code and noted the
index numbers were not the same as I had assigned, but was definitely
hesitant to tinker with it, given all the dire warnings about changing that
code. Thanks.
 
Thanks much Daniel! I spend half of my time making work what parts of CF and
SQLCE that do work and the other half figuring out how to get around "known
issues"....
 
Earl,

Reference your tabs by name as it makes life much easier ;-)

TabControl1.TabPages.IndexOf(TabPage1)

Rick
 
Back
Top