c# windows form Tab Order

Sertan Pekel picture Sertan Pekel · Oct 9, 2013 · Viewed 32.7k times · Source

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?

Answer

Trevor Elliott picture Trevor Elliott · Oct 9, 2013

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 a 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.