Tab key advancing to next text box

FlyingDoggyJake
09-22-2009, 02:03 PM
Hello again,

It seems to me that if you have a bunch of text boxes on a form and the user wishes to advance the focus from one text box to the next using the Tab key, it will advance in the order in which the text boxes were added to the form by the programmer.

eg. Imagine you had a form with text boxes laid out from top to bottom as so:

Text1
Text2
Text5
Text3
Text4

In this example, if you start with Text1 having the focus, the first Tab press would move the focus to Text2, the next Tab press would then skip over Text5 and put the focus on Text3, the next Tab press would then move down one text box to Text4 and then on the next Tab press it would jump back up to Text5.

I would like to be able to change it so that it moves from top to bottom regardless of the order in which I put the text boxes onto the form. Is there a simple way to do this or am I going to have to use such events as KeyDown, KeyPress...etc. on each text box and code in what I want done in the event that Tab is pressed?

This is not a huge issue, but I am curious if there's something I'm missing here.

Thanks

FireBot
09-22-2009, 02:31 PM
The property control.TabIndex determines this. It's incremented as controls are added. But you can change them yourself to make it work however you think is best.

FlyingDoggyJake
09-22-2009, 02:52 PM
doh! .... I always wondered what that "TabIndex" meant... you'd think I would have put 2 and 2 together here.
*feelin a little stupid right now

Thanks Firebot,
I appreciate it :)

mkaras
09-23-2009, 05:50 AM
A convenient trick to know about is this. Select the last control on the form and highlite its TabIndex property in the property box of the IDE. Then press "0" to make it the 'first tab order control'. Now walk backward through all your form controls and click on each one in turn and press "0" for each one. By the time you get to the first one in that reverse order game it will be TabIndex=0 and all the rest will be sequentially up in tab order to the "last" one being the highest number.

mkaras

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum