Skip to main content
.NET Framework 4.5.2+

Document.Selection Property

Gets or sets the selected range in the document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v22.1.Core.dll

Declaration

DocumentRange Selection { get; set; }

Property Value

Type Description
DocumentRange

A DocumentRange object, representing the DocumentRange.Start and DocumentRange.End positions of the selected text.

Remarks

Use the Document.Copy, Document.Cut and Document.Paste methods without parameters to work with selection in the document.

The DocumentRange.Start and DocumentRange.End properties of the Selection provides you with the positions which characterize the selection’s start and end.

Use the SubDocument.GetText method to obtain the plain text contained in the selection.

Example

document.LoadDocument("Grimm.docx", DocumentFormat.OpenXml)
Dim myStart As DocumentPosition = document.CreatePosition(69)
Dim myRange As DocumentRange = document.CreateRange(myStart, 216)
document.Selection = myRange

The following code snippets (auto-collected from DevExpress Examples) contain references to the Selection property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also