c# windows form Tab Order
Asked Answered
C

3

18

I have a windows form in C# project that keeps Student Info. I caught the image: enter image description here

I want to add data with sequential order as follows but when I enter data to Surname textbox, TAB button jumps to E-Mail textbox, then Phone Number textbox and lastly to Date of Birth DateTimePicker.

I made all control's TabStop property "False" on the form except these textboxes. And I arranged their TabOrder via Properties Section as follows 0,1,2.. as I intented. But the order followed as I wrote above. Then I opened Tab Order function via "View" on menu strip.. I clicked all controls which I wanted to use in order, but no use. The form and Tab button act as before. I caught Tab Order function image below:

enter image description here

What shall I do now?

Camail answered 9/10, 2013 at 17:1 Comment(1)
You've got controls behind controls, and controls inside panels, it's nearly impossible to actually get a feel for what the tab order really is. However, setting the TabStop to false isn't going to help matters - generally speaking - because that means you can't tab to that control.Cardiograph
M
25

TabIndex is important for controls which are siblings of the same parent. However, if your TextBox and ComboBox controls are each inside different parents then their parent controls must have the proper TabIndex.

In the Windows Forms Designer you can see which controls are children of which panels by bringing up the Document Outline. Go to View -> Other Windows -> Document Outline.

If each TextBox or ComboBox is directly inside a parent then its TabIndex doesn't matter, it can be 0. It's the parent (and possibly the parent's parent's) TabIndex which needs to be in order.

Mil answered 9/10, 2013 at 17:21 Comment(0)
P
8

Now that we have VS 2019. Simply go to form.cs[design], click "View" tab at the top of the page and select "Tab Order". This will allow you to click on the form elements in order of which you want them to be tabbed to. Any items not selected will not be tabbable(I think I made this word up). Once complete, click "Tab Order" again to exit view.

Porphyry answered 9/8, 2020 at 19:36 Comment(2)
This is a good answer, but it only works for .NET Framework WinForms apps, unfortunately.Zellers
It also works this way on VS 2015 but make sure you do this while the program is not running (or on pause) else it will not be stored.Delapaz
R
0

Designer:

enter image description here


Programmatic:

enter image description here

numericUpDown1.TabIndex = 0;
Ringo answered 21/4, 2023 at 13:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.