Partager via


SelText Property

Returns the text that the user selected in a text-entry area of a control, or returns an empty string ("") if no characters are selected. Specifies the string containing the selected text. Not available at design time; read/write at run time.

 [Form.]Control.SelText[= cString]

Return Value

  • cString
    Specifies the string containing the selected text or consists of an empty string if no characters are selected. Selected text appears shaded.

Remarks

Applies To: ComboBox | EditBox | Spinner | TextBox

Use this property with the SelLength and SelStart properties for tasks such as:

  • Setting the insertion point within a string of characters.

  • Establishing an insertion range that limits where the insertion point can go.

  • Selecting a specific group of characters (substrings) in a control.

  • Clearing text.

When working with these properties, be aware of the following behaviors:

  • Setting SelLength to less than 0 causes a run-time error.

  • Setting SelStart to greater than the text length sets the property to the existing text length. Changing SelStart changes the selection to an insertion point and sets SelLength to 0.

  • Setting SelText to a new value sets SelLength to 0 and replaces the selected text with the new string.

See Also

Reference

SelLength Property

SelStart Property

Other Resources

Properties (Visual FoxPro)