Tab Order

The tab order of controls determines the order in which users tab through controls on a form.

To modify the tab order of controls on the screen, select View | Show Tab Order from the main menu or hit Ctrl + T. This will open the Tab Order panel, in which you can drag and drop controls into the desired tab order. This panel can also be used as an alternate method of selecting a control on the form. It can also be used to change the z-order of controls on the form (a control that is at the bottom of the tab order collection will appear on top of any control above it).

 

BE AWARE THAT:

Modifying a control's tab order changes, not only the order in which users tab through controls on a form (and hence its TabIndex), but also the z-order and FormControlsCollectionIndex of the control you have repositioned and any subsequent controls.

The default tab order for any form is the same as the order in which the controls were created.

For example, assume you first create two text boxes, Text1 and Text2, and then a command button, Command1. When the application starts, Text1 has the focus. Pressing the Tab key moves the focus between controls in the order they were created, as show below.

You can set Command1 button to be first in the tab order by moving it to the top of the Tab Order collection.

The TabIndex for the other controls will be automatically adjusted upward, as listed in the following table.

Control

TabIndex before Command1 is first in tab order

TabIndex after Command1 is first in tab order  

Text1

0

1

Text2

1

2

Command1

2

0

The Tab Index is a zero-based index therefore the first control that the user tabs to will have a TabIndex of 0.

Note Controls that cannot get the focus, as well as disabled and invisible controls, are not included in the Tab order.

As you press the TAB key, these controls are skipped. Setting the TabStop property of a control to False will also prevent the control from being tabbed to.

Removing a control from the tab order

Normally, pressing the Tab key at run-time selects each control in tab order. You can remove a control from the tab order by setting its TabStop property to False (0).

A control whose TabStop property has been set to False still maintains its position in the actual tab order, even though the control is skipped when you cycle through the controls with the Tab key.

TIP:

An option button group has a single tab stop. The selected button (that is the button with its Value set to True) has its TabStop property automatically set to True, while the other buttons have their TabStop property set to False.

See Also


© 2004-2021 looksoftware. All rights reserved.