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!
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.
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.
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.
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.
Here is something you might want to give a try. From Code project. This will organize your tab index by 2 logicals ways.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With