Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab Index in Windows Forms

In my current application I have a form that requires the user to enter TONS of data. There are about 30 Textboxes and it happens that during development new ones get introduced or old ones get kicked out.

One Requirement by my customer is that they are all navigable through pressing Tab, and so I'm currently at the mercy of the TabIndex property if I see that correctly.

At the beginning I set those properties manually, but that required me to re-index them whenever I changed something.

I already tried to counter that problem by adding all FormDesigner generated controls to a List and loop through that list while setting the tabindex for the controls in that list.

Still, it doesn't work. Some of my controls still get focused out of order. I haven't really found a workaround, but will find one.

My question now is, why in the heck am I doing something like that in the first place? Is there some better way to handle tab-indexes or is this really how it's going to be? I mean, I was spending hours with that stupid designer setting tabindexes!

like image 954
Tigraine Avatar asked Nov 24 '08 15:11

Tigraine


People also ask

How do I create a tab control in Windows form?

To create a TabControl control at design-time, you simply drag and drop a TabControl control from Toolbox onto a Form in Visual Studio. After you drag and drop a TabControl on a Form, the TabControl1 is added to the Form and looks like Figure 1. A TabControl is just a container and has no value without tab pages.

What is the use of tab Index property of the control?

The following example uses the TabIndex property to display and set the tab order for individual controls. You can press Tab to reach the next control in the tab order and to display the TabIndex of that control. You can also click on a control to display its TabIndex.

What is tab order in a form?

Tab Order is the order or sequence that the cursor moves from field to field. Initially, the tab order is determined by the order in which the fields are added to the form.


2 Answers

When the forms designer is open go to View -> Tab Order this will allow you to set the tab order in a very simple and easy way.

like image 71
Yona Avatar answered Oct 25 '22 13:10

Yona


Here is something you might want to give a try. From Code project. This will organize your tab index by 2 logicals ways.

alt text

like image 37
Patrick Desjardins Avatar answered Oct 25 '22 15:10

Patrick Desjardins