HOWTO: How to Select Field on Entry on a Form in Visual FoxPro (135626)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0

This article was previously published under Q135626

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 achieve 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
    						

Modification Type:MinorLast Reviewed:3/3/2005
Keywords:kbhowto KB135626