tab control bug?

G

Guest

I have a form with a tab control containing several tabs. Using the tabPages
Collection editor (in design mode) I reordered the tabs using the up/down
arrow keys. When I click OK, the tabs are reordered in the design view as I
wanted. But, when I build the app, the tabs are put back in the original
order. I found that I can fix the problem by editing the windows form
designer generated code by changing the order that the tabs are added to the
tab control. This seems to be a bug but am I missing something? Also is it
safe to modify the designer generated code?
 
E

Eric Moreau

See an article I wrote in May 2004 about the TabControl from
http://emoreau.s2i.com/

In short:

The bad: The rearranging TabPages order

The bug that is the most irritating is probably the fact that the TabPages
of a TabControl occasionally rearrange themselves (change the order of
appearance). The problem was very frequent in VS.Net 2002. VS.Net 2003
improves it but didn't completely fix the problem.

You can easily fix that once for all with simple code. You can use the
following code to completely remove TabPages from the TabControl in re-add
them in the correct order. It is important to notice that the content of
TabPages will not be affected.

With TabControl1.TabPages
.Clear()
.Add(TabPage1)
.Add(TabPage2)
.Add(TabPage3)
.Add(TabPage4)
.Add(TabPage5)
End With
This code needs to be placed anywhere after the call to InitializeComponent.
The Form's Load event is a good place for that.

--


HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/
 
G

Guest

Thanks for the reply. You fix is essentially what I did but inside the
designer code. Putting it in Load sounds like a better idea. It has long
seemed a wonder to me that the tab controls in all ms development platforms
never seem to wok, it fact seemed to be the most buggy of all the controls.
This in sprite of the fact that the basic function of a tab control is very
simple. Click a btn, show one control and hide another one.
 

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