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.v23.1.Core.dll

NuGet Package: DevExpress.RichEdit.Core


DocumentRange Selection { get; set; }

Property Value

Type Description

A range that the selected text occupies.


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 allows you to obtain the selection’s start and end positions.

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

When you select individual table cells, the Selection property returns the last selected range. Use the Document.Selections property to obtain a collection of selections in the document. You can use the SelectionCollection to add new selection range or unselect previously selected range.


View Example

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

static void SelectTextInRange(Document document) {

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

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


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