Skip to main content

SelectionCollection Class

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

public class SelectionCollection :
    IEnumerable<DocumentRange>,
    IEnumerable

The following members return SelectionCollection objects:

Remarks

All ranges selected in the document are contained in this collection. To add an item to the collection, select a range with a keyboard or mouse, or use the SelectionCollection.Add method.

To toggle selection, that is to unselect a previously selected range, use the SelectionCollection.RemoveAt method.

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

Example

The code sample below shows how to select multiple ranges:

View Example

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

static void SelectMultipleRanges(Document document) {
    document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.OpenXml);
    DocumentRange range1 = document.CreateRange(80, 100);
    DocumentRange range2 = document.CreateRange(300, 100);
    int startPos3 = document.Tables[0].Rows[0].LastCell.ContentRange.Start.ToInt();
    DocumentRange range3 = document.CreateRange(startPos3, 100);
    DocumentRange range4 = document.CreateRange(720, 100);
    document.Selections.Add(new List<DocumentRange>() { range1, range2, range3, range4 });
}

Inheritance

Object
SelectionCollection

Extension Methods

See Also