Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Document.Selections Property

Retrieves a collection of selections in the document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core

#Declaration

SelectionCollection Selections { get; }

#Property Value

Type Description
SelectionCollection

A SelectionCollection object that contains ranges selected in the document.

#Remarks

The SelectionCollection contains all ranges selected in the document. To add an item to the collection, use the SelectionCollection.Add method.

Use the SelectionCollection.RemoveAt method to unselect previously selected range.

To unselect an arbitrary range, use the SelectionCollection.Unselect method.

#Example

The code sample below shows how to select a cell content:

View Example

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

static void SelectSingleRange(Document document) {
    document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.OpenXml);
    int startPos = 80;
    int endPos = document.Tables[0].Rows[1].LastCell.ContentRange.Start.ToInt();
    DocumentRange myRange = document.CreateRange(startPos, endPos - startPos);
    document.Selections.Add(myRange);
}
See Also