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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TabIndexChanged Event doesnt fire 1

Status
Not open for further replies.

golcarlad

Programmer
Nov 23, 2004
232
GB
Dont know why TabIndexChanged event never fires? - are there any peculiarities for this control that I dont know about?

Code:
private void tabControl1_TabIndexChanged(object sender, System.EventArgs e)
		{
			if(tabControl1.TabIndex ==1)
			{
				PopulateEcoRuleComboBox();
			}
		}
 
Hello,
you have mistaken it. Yes it fires.

Explanation:
- The TabIndex is the TAB's Index, not the tabpage's index. You set to several controls the PROPERTY TabIndex to 0, 1, 2 ... etc and those controls get focus when you press the TAB key of the keyboard.


I think you want to chack the tabpage, so:
The event handler should be:
Code:
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

And the if could be one of the below (select one):

Code:
        if (this.tabControl1.SelectedIndex == [COLOR=red]1[/color])
        if (this.tabControl1.SelectedTab == this.[COLOR=blue]tabPage2[/color])
        if (this.tabControl1.SelectedTab == this.tabControl1.TabPages[[COLOR=red]1[/color]])
        if (this.tabControl1.SelectedTab == this.tabControl1.TabPages[[COLOR=blue]"tabPage2"[/color]])


* NOTE *
The first tabPage is tabPage1 (the name), but the index is zero. So tabPage2 has index 1 and so on.


Hope this helps !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top