2013-08-03 58 views
0

如何在C#Window窗体中更改控件选择的顺序。我想改变表单中出现的文本框的位置,但是现在当我使用Tab键时,它将跳过该文本框并稍后转到该文本框。我和WPF一起工作过,我只是改变XAML中的控制位置,但我不能以Win的形式来完成。窗体控件选择

+2

设置Tab索引属性,你就完成了 – Rohit

回答

1

下面是一个简单的例子,增加了一个按钮,并设置其的TabIndex财产

// Create a button and add it to the form. 
Button button1 = new Button(); 

// Anchor the button to the bottom right corner of the form 
button1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right); 

// Assign a background image. 
button1.BackgroundImage = imageList1.Images[0]; 

// Specify the layout style of the background image. Tile is the default. 
button1.BackgroundImageLayout = ImageLayout.Center; 

// Make the button the same size as the image. 
button1.Size = button1.BackgroundImage.Size; 

// Set the button's TabIndex and TabStop properties. 
button1.TabIndex = 1; 
button1.TabStop = true; 

// Add a delegate to handle the Click event. 
button1.Click += new System.EventHandler(this.button1_Click); 

// Add the button to the form. 
this.Controls.Add(button1); 

另外,您还可以看看this(从设计设置)

希望它可以帮助

+0

是的,它是TabIndex属性。谢谢 – user2081328

+1

如果它可以帮助你,请随时将其标记为答案:) – Rohit