Reputation: 73
I have the this code to disable tab page:
private void tabControl_Selecting(object sender, TabControlCancelEventArgs e)
{
if (e.TabPage == tabPage)
{
e.Cancel = true;
}
}
and i want to enable it when a button is click. Is there a way to do it?
Upvotes: 0
Views: 556
Reputation: 7095
declare bool property in your form, something like this:
public Form1
{
bool TabSelectingAllowed {get;set;}
when user clicks on button, change value
private void button1_Click(object sender, EventArgs e)
{
TabSelectingAllowed = true;
}
in you existing code add additional checking for value of that property
private void tabControl_Selecting(object sender, TabControlCancelEventArgs e)
{
if (e.TabPage == tabPage)
{
if (!TabSelectingAllowed)
e.Cancel = true;
}
}
Upvotes: 1