The requested page is not available for the requested platform. You are viewing the content for Default platform.

RichEditSelection Class

Contains a set of methods and properties to work with the document selection.

Declaration

export class RichEditSelection

Remarks

An instance of the RichEditSelection object can be accessed by the selection property.

Properties

active Property

Gets a position where a user ends the selection.

Declaration

readonly active: number

Property Value

Type Description
number

The active selection position (the cursor position).

Remarks

Users can make a selection from left to right or from right to left. Use the anchor property to get the position where a user starts the selection. To get the position where the user ends the selection, use the active property.

activeSubDocument Property

Returns the active sub-document.

Declaration

readonly activeSubDocument: SubDocumentBaseApi

Property Value

Type Description
SubDocumentBaseApi

The active sub-document.

anchor Property

Gets a position where a user starts the selection.

Declaration

readonly anchor: number

Property Value

Type Description
number

The position of the selection anchor.

Remarks

Users can make a selection from left to right or from right to left. Use the anchor property to get the position where a user starts the selection. To get the position where the user ends the selection, use the active property.

end Property

Gets the selection's end position.

Declaration

readonly end: number

Property Value

Type Description
number

The end position.

intervals Property

Gets an array of document intervals in the selection.

Declaration

readonly intervals: Interval[]

Property Value

Type Description
Interval[]

An array of Interval objects.

start Property

Gets the selection's start position.

Declaration

readonly start: number

Property Value

Type Description
number

The start position.

Methods

goToSubDocumentEnd Method

Moves the cursor to the end of the sub-document and allows you to extend the selection.

Declaration

goToSubDocumentEnd(extendSelection?: boolean): void

Optional Parameters

Name Type Default Description
extendSelection boolean null

true, to extend the selection; otherwise, false.

Remarks

richEdit.selection.goToSubDocumentEnd(true);

selectAll Method

Selects the editor's entire content.

Declaration

selectAll(): void

Remarks

richEdit.selection.selectAll();

setSelection(position) Method

Selects the specified interval(s).

Declaration

setSelection(position: number | IInterval | IInterval[]): void

Parameters

Name Type Description
position number | IInterval | IInterval[]

The interval(s) or position to select.

Remarks

function onDocumentLoaded(s, e) {
    s.document.insertText(0, 'Dear Mr Stanley,');
    s.document.insertParagraph(s.document.length);
    var startPosition = s.document.length;
    s.document.insertParagraph(startPosition);
    s.document.insertText(startPosition, '[Type your text here]');
    s.selection.setSelection(new DevExpress.RichEdit.Interval(startPosition, s.document.length - startPosition));
    s.focus();
}

For a full example, see Ribbon Customization demo.