Microsoft KB Archive/171983

From BetaArchive Wiki

Article ID: 171983

Article Last Modified on 8/21/1999


  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition

This article was previously published under Q171983


When setting the SelectOnEntry property in Visual FoxPro 5.0 to True (.T.), a single character is not highlighted when the object receives focus with some objects.

Of all the objects in Visual FoxPro 5.0 that use the SelectOnEntry property, the TextBox and ComboBox are the ones that do not highlight a single character properly. The EditBox, Spinner, and Grid column objects highlight a single character properly. If any of the object just mentioned has more than one character in it, then the characters are highlighted properly when the SelectOnEntry is set to True.

The same problem occurs when using the "K" setting in the Format property of the TextBox or ComboBox. Setting the Format property to "K" selects all text when the object receives focus. The SelectOnEntry property was not available in Visual FoxPro 3.0. The Format property value of "K" works properly with just one character in Visual FoxPro 3.0 and, therefore, the workaround below is not necessary. The ComboBox in Visual FoxPro 3.0 does not have a Format property or the SelectOnEntry property.


To allow a single character to become highlighted in a TextBox or ComboBox, check the length of the value to see if it is a single character. If it is only one character in length, using the KEYBOARD command allows the character to be highlighted. Place the following code into the Gotfocus event:

   IF LEN(ALLTRIM(THIS.VALUE)) = 1 && Use This.Value works for
   *                                  textboxes,
      KEYBOARD '{shift + home}'    && and This.DisplayValue for
   *                                 Comboboxes.
      KEYBOARD '{shift + rightarrow}'


Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Steps to Reproduce Behavior

  1. Create a form and place a TextBox, ComboBox, and EditBox on the form.
  2. Change the SelectOnEntry property to True for each of the objects.
  3. After running the form, type one character into each of the objects. Tab through the objects and note that the single character in the EditBox is the only character that gets highlighted.
  4. Type more than one character into each of the objects and tab through the objects. Note that the characters in each object gets highlighted properly.

Additional query words: form designer

Keywords: kbprb KB171983