SelectedLength

Description

Determines the total number of characters in the selected text in an editable control, including spaces and line endings.

Applies to

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

Syntax

editname.SelectedLength ( )

Argument

Description

editname

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

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


Return value

Integer for DataWindow, InkEdit, and list boxes, Long for other controls.

Returns the length of the selected text in editname. If no text is selected, SelectedLength returns 0. If an error occurs, it returns -1. If editname is null, SelectedLength returns null.

Usage

Except for text in rich text controls, the characters that make up a line ending (produced by typing Ctrl+Enter or Enter) can be different on different platforms. On Windows, it is a carriage return plus a line feed and equals two characters when calculating the length. On other platforms, a line ending is a single character. A line that has wrapped has no line-ending character. For DropDownListBox and DropDownPictureListBox controls, SelectedLength returns -1 if the control's AllowEdit property is set to false.

RichTextEdit controls

For rich text controls, a carriage return plus a line feed always count as a single character when calculating the text length.

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 selected text in the MultiLineEdit mle_Contact is John Smith, then this example sets li_length to 10:

long ll_length
ll_length = mle_Contact.SelectedLength()

See also

LineLength

SelectedItem

SelectedLine

SelectedPage

SelectedStart

TextLine