SelectedLength

Description

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

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control


Syntax

PowerBuilder

long dwcontrol.SelectedLength ( )

Argument

Description

dwcontrol

A reference to a DataWindow control. SelectedLength reports the length of the selected text in the edit control over the current row and column.


Return value

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

If dwcontrol is null, in PowerBuilder and JavaScript the method returns null.

Usage

The characters that make up a line ending, produced by typing Ctrl+Enter or Enter, are different on different platforms. On Windows, they are a carriage return plus a line feed and equal two characters when calculating the length. On other platforms, a line ending can be a single character. A line that wraps has no line-ending character.

RichText DataWindows

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

PowerBuilder environment

For use with other PowerBuilder controls, see the section called “SelectedLength” in PowerScript Reference.

Examples

If the selected text in the DataWindow dw_Contact is John Smith, then this example sets the variable to 10, the number of selected characters:

integer li_length
li_length = dw_Contact.SelectedLength()

See also

SelectedLine

SelectedStart

TextLine