TabControls Selecting
Event will disable switching, but we need to keep track of button's click
with a bool
value, otherwise button's click
won't select the tab either.
bool checkCancel = true;
private void button2_Click(object sender, EventArgs e)
{
checkCancel = false;
tabControl1.SelectTab("tabPage2");
}
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
e.Cancel = checkCancel;
checkCancel = true;
}
Result, (btw trying to click to tabpages at the gif :))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…