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

Web ActiveX

DataWindow control

Syntax

PowerBuilder

long dwcontrol.SelectedLength ( )

Web ActiveX

number 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.

Returns

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.

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

NotePowerBuilder environment For use with other PowerBuilder controls, see SelectedLength in the PowerScript Reference.

Examples

Example 1

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