SelectedText

Description

Obtains the selected text in an editable control.

Applies to

DataWindow, EditMask, InkEdit, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, and DropDownPictureListBox controls

Syntax

editname.SelectedText ( )

Argument

Description

editname

The name of the DataWindow, EditMask, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, or DropDownPictureListBox control from which you want the selected text.

For a DropDownListBox or DropDownPictureListBox, the AllowEdit property must be true.

For a DataWindow, it reports the selected text in the edit control over the current row and column.


Return value

String.

Returns the selected text in editname. If there is no selected text or if an error occurs, SelectedText returns the empty string (""). If editname is null, SelectedText returns null.

Usage

In a RichTextEdit control, any pictures in the selection are ignored. If the selection contains input fields, the names of the input fields, enclosed in brackets, become part of the string SelectedText returns. The contents of the input fields are not returned.

For example, when the salutation of a letter is selected, SelectedText might return:

Dear {title} {lastname}:

Focus and the selection in a drop-down list

When a DropDownListBox or DropDownPictureListBox loses focus, the selected text is no longer selected.

Examples

If the text in the MultiLineEdit mle_Contact is James B. Smith and James B. is selected, these statements set the value of emp_fname to James B:

string ls_emp_fname
ls_emp_fname = mle_Contact.SelectedText()

If the selected text in the edit portion of the DropDownListBox ddlb_Location is Maine, these statements display the ListBox lb_LBMaine:

string ls_Loc
ls_Loc = ddlb_Location.SelectedText()
IF ls_Loc = "Maine" THEN
      lb_LBMaine.Show()
ELSE
      ...
END IF

See also

SelectText