How to Position the Insertion Point in a Field on a Form

Last reviewed: April 30, 1996
Article ID: Q127009
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

This articles describes how to control the order in which objects are selected on a form.

MORE INFORMATION

When a form is displayed, the first object added to the form is by default the first one accessed. When users tab through the form, the highlight moves by default according to the order that the objects were added. It is possible to control navigation in a form through the use of the TABINDEX property or the SETFOCUS method.

Using the TABINDEX Property

This property specifies the Tab order of form objects in a Form. For example, say you have a form with two command buttons (CmdButton1 and CmdButton2). You can use the TabIndex property if you want to access CmdButton2 before CmdButton1 as users press the TAB key. To achieve this, in the Form Designer, select the TabIndex property in the Property Sheet and modify its value. You can also modify the value of the TabIndex property under program control. For example:

   frmtest.CmdButton1.tabindex=2

The TabIndex property will be ignored if the TabStop property is set to .F. for that control.

Using the SETFOCUS Method

The SetFocus method assigns the focus to a control. Use this method to move the focus from one control in the form to another conditionally. For example, if there are three command buttons on a form and you want to shift the focus from CmdButton1 to CmdButton3 when the user clicks the CmdButton1 button, include the following code in the Click event handler:

   Thisform.CmdButton3.SetFocus

Focus is set to CmdButton3 as the SetFocus method is invoked.

For more information about the TabIndex property and the SetFocus method, search for TabIndex and SetFocus using the FoxPro Help system.


Additional reference words: VFoxWin 3.00 curobj select highlight
KBCategory: kbtool kbprg
KBSubcategory: FxtoolFormdes


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.