2013-08-03 4 views
0

Как изменить порядок выбора управления в форме окна C#. Я хотел изменить, где текстовое поле появляется в форме, но теперь, когда я использую клавишу Tab, он пропускает это текстовое поле, а затем переходит к нему. Я работал с WPF, и я бы просто изменил позицию управления в XAML, но я не могу сделать это в форме Win.Выбор формы управления

+2

Задайте свойство индекса вкладки, и все готово – 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

Смежные вопросы