Hi,
As far as I know, a tab page doesn't have an Enabled property. In the code you use,
SelectedIndex
only set or get the tab controls selected index, it does not change the property of the page.
You can achieve similar effect by disabling the controls in that page or cancel the selection event.
This is one of the easy way of disabling the contents in the page
((Control)this.tb3).Enabled = false;
Or you can cancel the selection event if user select tb3.
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
if (this.tabControl1.SelectedTab.Name == "tb3")
{
e.Cancel = true;
}
}
This way, user cannot even view the content of the page, they just know there's a tb3 exists. Note that the event handeler is
tabControl1_Selecting
not
tabControl1_SelectedIndexChanged
. In your case I think the second option fits your requirement more.
Hope this is helpful.