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

tabcontrol1 event

Status
Not open for further replies.

prrm333

Programmer
Apr 14, 2003
97
US
I'm trying to get something similar to below to work to hide or disable a textbox when a particular tab is active or selected. The following code doesn't seem to do anything:

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.tabControl1.SelectedIndex == 1)

{
textbox1.Visible = false;
}
}
 
It is working for me.
Two notes by the way
1. The index 1 is for the second tabpage because the start at zero.
2. I see you left the default names. C# is case sensitive so textbox1 is not the same as textBox1
 
I don't know if this changes anything but the textbox I am trying to hide is on the main form and not on any of the pages of the tabControl. In my naming convention I hadn't gotten around to changing the name yet. Anyway it still doesn't work, any ideas?

Thanks.
 
I figured out what the problem was. In the .designer.cs tab the following was missing from the tabControl1 properties:

this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top