日期:2014-05-18 浏览次数:21196 次
public partial class Form1 : Form { public Form1() { InitializeComponent(); tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_Selecting); } void tabControl1_Selecting(object sender, TabControlCancelEventArgs e) { if (e.TabPageIndex == 1) e.Cancel = true; } }
------解决方案--------------------
搞成这样也行...
public partial class Form1 : Form { public Form1() { InitializeComponent(); tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_Selecting); tabPage2.Tag = true; tabPage3.Tag = true; } void tabControl1_Selecting(object sender, TabControlCancelEventArgs e) { if (e.TabPage.Tag!=null&&(bool)e.TabPage.Tag) e.Cancel = true; } }