我以前做B|S,最近因工作需要做C|S的
请问在window form中的tabControl控件 比如tabControl1有三个选项taba,tabb,tabc
能够在点击其中某一个时没有反映么(如:现在是在选项taba的page中,点击tabb不切换到tabb)

解决方案 »

  1.   

    不太懂楼主为什么要这样,不用tabControl就可以啊
    点击一个肯定有反映的啊
      

  2.   

    private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    if(tabControl1.SelectedIndex==1)
    this.tabControl1.SelectedIndex=0;
    }
      

  3.   

    //完整代码如下:using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace TestApp
    {
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TabControl tabControl1;
    private System.Windows.Forms.TabPage tabPage1;
    private System.Windows.Forms.TabPage tabPage2;
    private System.Windows.Forms.TabPage tabPage3;
    private System.ComponentModel.Container components = null; public Form1()
    {
    InitializeComponent();
    } protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
            private void InitializeComponent()
    {
    this.tabControl1 = new System.Windows.Forms.TabControl();
    this.tabPage1 = new System.Windows.Forms.TabPage();
    this.tabPage2 = new System.Windows.Forms.TabPage();
    this.tabPage3 = new System.Windows.Forms.TabPage();
    this.tabControl1.SuspendLayout();
    this.SuspendLayout();
    // 
    // tabControl1
    // 
    this.tabControl1.Controls.Add(this.tabPage1);
    this.tabControl1.Controls.Add(this.tabPage2);
    this.tabControl1.Controls.Add(this.tabPage3);
    this.tabControl1.Location = new System.Drawing.Point(24, 56);
    this.tabControl1.Name = "tabControl1";
    this.tabControl1.SelectedIndex = 0;
    this.tabControl1.Size = new System.Drawing.Size(240, 144);
    this.tabControl1.TabIndex = 0;
    this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
    // 
    // tabPage1
    // 
    this.tabPage1.Location = new System.Drawing.Point(4, 21);
    this.tabPage1.Name = "tabPage1";
    this.tabPage1.Size = new System.Drawing.Size(232, 119);
    this.tabPage1.TabIndex = 0;
    this.tabPage1.Text = "tabPage1";
    // 
    // tabPage2
    // 
    this.tabPage2.Location = new System.Drawing.Point(4, 21);
    this.tabPage2.Name = "tabPage2";
    this.tabPage2.Size = new System.Drawing.Size(232, 119);
    this.tabPage2.TabIndex = 1;
    this.tabPage2.Text = "tabPage2";
    // 
    // tabPage3
    // 
    this.tabPage3.Location = new System.Drawing.Point(4, 21);
    this.tabPage3.Name = "tabPage3";
    this.tabPage3.Size = new System.Drawing.Size(232, 119);
    this.tabPage3.TabIndex = 2;
    this.tabPage3.Text = "tabPage3";
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.Add(this.tabControl1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.tabControl1.ResumeLayout(false);
    this.ResumeLayout(false); }
    #endregion [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    if(tabControl1.SelectedIndex==1)
    this.tabControl1.SelectedIndex=0;
    }
    }
    }//测试通过