好像不能禁神烂用单个TabPage。不过游带漏你可以这样操行拦作。
在控件的TabPages里面给每个TabPage定义一个Name。
找到TabControl控件的事件(SelectedIndexChanged)。根据当前选中的TabPage来判断操控它。
public Form1()
{
InitializeComponent();
tbControl.Selecting += new TabControlCancelEventHandler(tbControl_Selecting);
}
int i = 0;
bool f1 = true;
bool f2 = true;
bool f3 = true;
private void tbControl_Selecting(object sender, TabControlCancelEventArgs e)
{
if (e.TabPageIndex == 0) e.Cancel = f1;
if (e.TabPageIndex == 1) e.Cancel = f2;
if (e.TabPageIndex == 2) e.Cancel = f3;
}
private void button2_Click(object sender, EventArgs e)
{
i = 0;
i++;
if (i > 0)
{
f1 = true;
f2 = false;
f3 = true;
}
this.tbControl.SelectedIndex = 1;
}
private void button5_Click(object sender, EventArgs e)
{
i = 0;
i++;
if (i > 0)
{
f1 = true;
f2 = true;
f3 = false;
}
this.tbControl.SelectedIndex = 2;
}
private void button4_Click(object sender, EventArgs e)
{
i = 0;
i++;
if(i>0)
{
f1 = false;
f2 = true;
f3 = true;
}
this.tbControl.SelectedIndex = 0;
}
private void button8_Click(object sender, EventArgs e)
{
i = 0;i++;
if(i>0)
{
f1 = true;
f2 = false;
f3 = true;
}
this.tbControl.SelectedIndex = 1;
}