我有一个包含一些文本框和按钮的表单的子面板。我尝试为这些控件设置 tabstop 和 tabindex 属性,以便用户可以从一个控件切换到下一个控件。但是由于某种原因,制表符不起作用,当我按下制表键时,光标停留在具有焦点的同一字段上。我正在使用带有 .Net 3.5 框架的 C#。下面是我的代码的样子 -
rightPanel.Controls.Clear();
marketMessageLabel = new Label();
marketMessageLabel.Location = new Point(0, 20);
marketMessageLabel.AutoSize = false;
marketMessageLabel.Size = new Size(rightPanel.Width, 42);
marketMessageLabel.BackColor = Color.White;
marketMessageLabel.Font = new System.Drawing.Font("Verdana", 8.00F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
rightPanel.Controls.Add(marketMessageLabel);
signinUserNameLabel = new Label();
signinUserNameLabel.Location = new Point(0, 150);
signinUserNameLabel.Size = new Size(60, 14);
signinUserNameLabel.BackColor = Color.White;
signinUserNameLabel.Text = "User Name";
signinUserNameLabel.Font = new System.Drawing.Font("Verdana", 9.00F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
rightPanel.Controls.Add(signinUserNameLabel);
signinUserNameTextBox = new TextBox();
signinUserNameTextBox.Location = new Point(0, 170);
signinUserNameTextBox.Width = this.Width - 80;
signinUserNameTextBox.Font = new System.Drawing.Font("Verdana", 9.00F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
signinUserNameTextBox.TabIndex = 0;
signinUserNameTextBox.TabStop = true;
rightPanel.Controls.Add(signinUserNameTextBox);
signinPasswordLabel = new Label();
signinPasswordLabel.Location = new Point(0, 192);
signinPasswordLabel.Size = new Size(100, 14);
signinPasswordLabel.Font = new System.Drawing.Font("Verdana", 9.00F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
signinPasswordLabel.BackColor = Color.White;
signinPasswordLabel.Text = "Password";
rightPanel.Controls.Add(signinPasswordLabel);
signinPasswordTextBox = new TextBox();
signinPasswordTextBox.Location = new Point(0, 210);
signinPasswordTextBox.Width = this.Width - 80;
signinPasswordTextBox.PasswordChar = '*';
signinPasswordTextBox.TabIndex = 1;
signinPasswordTextBox.TabStop = true;
rightPanel.Controls.Add(signinPasswordTextBox);
signInButton = new Button();
signInButton.Text = "Sign In";
signInButton.Font = new System.Drawing.Font("Verdana", 9.00F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
signInButton.Width = 70;
signInButton.BackColor = Color.White;
signInButton.Location = new Point(0,240);
signInButton.Click += new EventHandler(signInButton_Click);
signInButton.TabIndex = 2;
signInButton.TabStop = true;
rightPanel.Controls.Add(signInButton);