How to Select Field on Entry on a Form in Visual FoxPro

Last reviewed: December 14, 1995
Article ID: Q135626
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

The Screen Designer in FoxPro version 2.x products has a check box in the Field dialog box under Options labeled Select Field on Entry. The check box is selected by default, and the format picture clause "@K" is generated for the field so that when the form is run and the field entered, its contents are selected. This option is no longer set by default in Visual FoxPro.

MORE INFORMATION

To acheive the same select-on-entry behavior in Visual FoxPro, use any one of these techniques:

  • Set the Format property of each text box to K, and set SelectedBackColor to 0,0,128.

    -or-

  • Add the following lines of code to the Init event procedure of the form:

    THISFORM.SetAll("Format","K","Textbox") THISFORM.SetAll("SelectedBackColor",RGB(0,0,128),"Textbox")

    -or-

  • In the GotFocus event procedure of a text object, enter this code:

    NODEFAULT textbox::GotFocus this.sellength=LEN(<fldname>)

    -or-

  • In the GotFocus method of the object, place the following code:

          IF !EMPTY(this.value)
           KEYBOARD "{end}"
           KEYBOARD "{shift+home}"
          ENDIF
    


Additional reference words: 3.00 VFoxWin selected text seltext selstart
KBCategory: kbprg
KBSubcategory: FxprgGeneral


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: December 14, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.