TabIndex无法正常工作

8 .net c# winforms

我有一个Windows窗体应用程序.在表单上有三个groupbox.每个组框都包含一些控件.请看图像. 形成

有一个groupbox"flag",其中包含几个复选框."flag"位于"groupbox1"中.我使用Tab键来浏览每个控件,但它不适用于"flag"中的复选框.我确实为每个控件设置了正确的tabindex.

它适用于文本框和按钮,但复选框.

为什么?感谢帮助.

编辑

 // groupBox2
        // 
        this.groupBox2.Controls.Add(this.pictureBox10);
        this.groupBox2.Controls.Add(this.pictureBox9);
        this.groupBox2.Controls.Add(this.pictureBox8);
        this.groupBox2.Controls.Add(this.pictureBox7);
        this.groupBox2.Controls.Add(this.chkStoplight);
        this.groupBox2.Controls.Add(this.lblStoplight);
        this.groupBox2.Controls.Add(this.chkIsCount);
        this.groupBox2.Controls.Add(this.chkExceptionFlag);
        this.groupBox2.Controls.Add(this.chkIsActive);
        this.groupBox2.Controls.Add(this.lblIsActive);
        this.groupBox2.Controls.Add(this.lblExceptionFlag);
        this.groupBox3.Controls.Add(this.lblIsCount);
        this.groupBox2.Location = new System.Drawing.Point(16, 201);
        this.groupBox2.Name = "groupBox2";
        this.groupBox2.Size = new System.Drawing.Size(321, 70);
        this.groupBox2.TabIndex = 10;
        this.groupBox2.TabStop = true;
        this.groupBox2.Text = "Flags";

        // 
        // chkStoplight
        // 
        this.chkStoplight.AutoSize = true;
        this.chkStoplight.Location = new System.Drawing.Point(44, 25);
        this.chkStoplight.Name = "chkStoplight";
        this.chkStoplight.Size = new System.Drawing.Size(15, 14);
        this.chkStoplight.TabIndex = 0;
        this.chkStoplight.UseVisualStyleBackColor = true;

        In the property, I found TabStop is true for chkStoplight.
Run Code Online (Sandbox Code Playgroud)

Jon*_*yna 11

对于System.Windows.Forms.GroupBox:

您应确保GroupBox flag具有适当的TabIndex集.

MSDN - 如何:在Windows窗体上设置Tab顺序:

此外,默认情况下,GroupBox控件具有自己的TabIndex值,这是一个整数.GroupBox控件本身在运行时无法获得焦点.因此,GroupBox中的每个控件都有自己的十进制TabIndex值,以.0开头.当然,随着GroupBox控件的TabIndex递增,其中的控件将相应递增.如果将TabIndex值从5更改为6,则其组中第一个控件的TabIndex值将自动更改为6.0,依此类推

此外,请确保GroupBox 的TabStop属性flag未设置为false.我相信假是默认的.

对于System.Windows.Controls GroupBox:

确保已设置GroupBox.IsTabStop属性.这也默认为false.

更新:似乎正在添加所有控件groupBox3.您应该确保每个都只添加到其包含的组框中.例如checkBox1,checkBox2checkBox3都应该加入flag,这本身应该加入groupBox1. groupBox3应该只包含Back,Next,Finish和Cancel.