TabIndex

This property determines the tab order of controls within a container. It's maintained separately for different containers, so you can do things like order the buttons in a group separately from the order of controls on the form.

Usage

oObject.TabIndex = nTabOrder
nTabOrder = oObject.TabIndex
This property determines the sequence of data entry in your form—the route through the controls the user will take if she presses the arrow keys or Tab to move from one control to the next. The order in which a user tabs through the controls in a form does not have to be the same as the creation order of the controls. TabIndex lets you determine the tab order. Every container except grids and page frames, which have different properties for this (so much for polymorphism), lets you set TabIndex for each control inside that accepts focus. When you tab (or arrow, in some cases) through the controls in that container, the order you see is the TabIndex order of those controls. The structure used here is well thought out. Rather than numbering every control on a form in one sequence at the form level, you specify the order only for those controls directly contained on the form. If some of those controls contain others (for example, command groups contain command buttons), you number the items inside that container independently from the form. So each command group, option group and page has its own numbering sequence, no matter how deeply it's nested. The container has a TabIndex (or in the case of pages, PageOrder) that determines its sequence within the form or page that holds the container. This approach makes it easy to reorder things without fouling up the work you've already done.At design-time, the Tab Order option on the View menu lets you manipulate TabIndex without having to fiddle in the Property Sheet. Think of it as an "Order Builder."We suggest you use the Tab Order menu option, rather than manipulating values on the Property Sheet. There are two methods of ordering available at design-time. You choose the one you want in the Tools-Options dialog, under the Forms tab. You can set Tab Ordering to be either "Interactive" or "By List," our preference. It's easy to get confused about the TabIndexes of objects in a group. When you change one, the others don't change to fill in the gaps, so you can end up with several objects with identical TabIndexes. (Don't know why VFP can't adjust them. Other properties like PageOrder are smart enough to do this. On the other hand, that automatic adjustment makes manipulating PageOrder really tough, so maybe there's no good solution to this one.)

You can use the Tab Order dialog to reorder at any level. Just right-click, Edit on the container you want to reorder, then choose View-Tab Order from the menu. The dialog lets you reorder the objects inside the chosen container. Very cool!


You can change the TabIndex at runtime, too (though it suffers from the same confusion as at design-time), but we suggest you don't. Except in very unusual circumstances, changing the order in which the user tabs through the controls definitely falls into the category of a user-hostile interface.

Example

ThisForm.cmgNavButtons.cmdTop.TabIndex = 1

See Also

ColumnOrder, CommandGroup, OptionGroup, Page, PageOrder, ZOrder


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .