Click to See Complete Forum and Search --> : Form Designer Bug


JetDeveloper
December 1st, 2004, 03:45 PM
I have a project that has a form with a TabControl and lots of TabPages. There are too many tab pages to fit on the tab control, so it has a scroll arrow that allows you to scroll to the tab pages that do not fit.

There is a serious problem. The InitializeComponent() code generated by Form Designer keeps changing the order in which it adds the tab pages.


For example I start with


// InitializeCompnent
this.tabCtrl1.Controls.Add(tabPage1);
this.tabCtrl1.Controls.Add(tabPage2);
this.tabCtrl1.Controls.Add(tabPage3);
this.tabCtrl1.Controls.Add(tabPage4);
this.tabCtrl1.Controls.Add(tabPage5);


Then I add a button or something to one of the pages and I get


// InitializeCompnent
this.tabCtrl1.Controls.Add(tabPage3);
this.tabCtrl1.Controls.Add(tabPage1);
this.tabCtrl1.Controls.Add(tabPage2);
this.tabCtrl1.Controls.Add(tabPage5);
this.tabCtrl1.Controls.Add(tabPage4);


I have to keep changing it back to the correct order and everytime I edit the form in the designer, it rewrites InitializeComponent and puts the pages in the wrong order again. The ordering seems to be very random each time.

Is this a known bug in C#? If so, they better fix it in the next release of .NET.

Thanks in advance

Andy Tacker
December 2nd, 2004, 05:49 AM
this is a bug and remains valid even in new version.
the solution is manully changing them in the code...