Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tabpage order issue

Status
Not open for further replies.

kmfna

MIS
Sep 26, 2003
306
US
Hello all,

I have recently created a tab control in a program, and the tabpage order keeps changing around on me...when I looked up this problem, it seems that .net has a bug that causes this...I have tried to manually set the order, but have not been able to get it to work. The following are a few of the ways that I have tried...

In InitializeComponents():

Code:
this.tabControl1.Controls.SetChildIndex(this.tbHome, 0);
this.tabControl1.Controls.SetChildIndex(this.tbAccount, 0);
this.tabControl1.Controls.SetChildIndex(this.tbAdministration, 0);
this.tabControl1.Controls.SetChildIndex(this.tbCPTLookUp, 0);
this.tabControl1.Controls.SetChildIndex(this.tbPPOProviderLookUp, 0);
this.tabControl1.Controls.SetChildIndex(this.tbReporting, 0);
this.tabControl1.Controls.SetChildIndex(this.tbEDI, 0);
this.tabControl1.Controls.SetChildIndex(this.tbPhysician, 0);
this.tabControl1.Controls.SetChildIndex(this.tbPatient, 0);
this.tabControl1.Controls.SetChildIndex(this.tbRepricing, 0);
----- AND -----
Code:
this.tabControl1.Controls.SetChildIndex(this.tbHome, 1);
this.tabControl1.Controls.SetChildIndex(this.tbAccount, 2);
this.tabControl1.Controls.SetChildIndex(this.tbAdministration, 3);
this.tabControl1.Controls.SetChildIndex(this.tbCPTLookUp, 4);
this.tabControl1.Controls.SetChildIndex(this.tbPPOProviderLookUp, 5);
this.tabControl1.Controls.SetChildIndex(this.tbReporting, 6);
this.tabControl1.Controls.SetChildIndex(this.tbEDI, 7);
this.tabControl1.Controls.SetChildIndex(this.tbPhysician, 8);
this.tabControl1.Controls.SetChildIndex(this.tbPatient, 9);
this.tabControl1.Controls.SetChildIndex(this.tbRepricing, 10);
----- AND -----
Code:
this.tabControl1.Controls.SetChildIndex(this.tbHome, 1);
this.tabControl1.Controls.SetChildIndex(this.tbAccount, 1);
this.tabControl1.Controls.SetChildIndex(this.tbAdministration, 1);
this.tabControl1.Controls.SetChildIndex(this.tbCPTLookUp, 1);
this.tabControl1.Controls.SetChildIndex(this.tbPPOProviderLookUp, 1);
this.tabControl1.Controls.SetChildIndex(this.tbReporting, 1);
this.tabControl1.Controls.SetChildIndex(this.tbEDI, 1);
this.tabControl1.Controls.SetChildIndex(this.tbPhysician, 1);
this.tabControl1.Controls.SetChildIndex(this.tbPatient, 1);
this.tabControl1.Controls.SetChildIndex(this.tbRepricing, 1);

Any help would be greatly appreaciated.

Thanks in advance,
Kevin


- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
For EACH call of SetChildIndex(ctl, newindex), the ctl control is moved on the newindex position and other tabPages are reordered to accommodate this move.
The control with the index value of zero is at the top of the z-order.
Here is a host form with the tabControl1 object.
The tabControl1 contains 4 TabPage objects: tabPage1, tabPage2, tabPage3, tabPage4.
The order of the pages is the order in which the pages are added in the TabControl:
Code:
this.tabControl1.Controls.AddRange(new Control[] {
            this.tabPage4, 
            this.tabPage3,  
            this.tabPage2,  
            this.tabPage1}); 


// Selects tabPage3 using SelectedIndex.
this.tabControl1.SelectedIndex = 1;

// Selects tabPage2 in at run time 

private void timer1_Tick(object sender, System.EventArgs e)
{
        //
	this.tabControl1.SelectedIndex = 2;
	//
}
Note that a TabPage can contain a TabControl which in turn can contain TabPages.
Each TabControl manages the order of its TabPages.
If you want to change the order of the tabPages to be tabPage1 ->0, tabPage2->1, tabPage3->2, tabPage4->3 use:
Code:
this.tabControl1.Controls.SetChildIndex(this.tabPage1, 0); // The order is tabPage1, tabPage4, tabPage3, tabPage2
this.tabControl1.Controls.SetChildIndex(this.tabPage2, 1); // The order is tabPage1, tabPage2, tabPage4, tabPage3
this.tabControl1.Controls.SetChildIndex(this.tabPage3, 2); // The order is tabPage1, tabPage2, tabpage3, tabPage4
-obislavu-
 
Right....I designed each of the ways that I did it with ZOrder in mind, the problem is that my changes aren't being reflected at run time, so I was confused if I was doing something wrong. According to your example it is right, so I'm still confused about why it isn't actually doing anything....Oh well, I suppose that the order can just be a surprise to us, while designing..and while not best practices, we can just refer to the name of the tab as opposed to the index.

Thanks,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top