Skip to main content
.NET Framework 4.5.2+

SelectionCollection.Add(DocumentRange) Method

Adds a range to the collection of selections.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core


public void Add(
    DocumentRange range


Name Type Description
range DocumentRange

A DocumentRange to add.


When several ranges is added to the collection, they do not necessarily retain its origin. The resulting items contained in the collection can be formed by merging or splitting the specified ranges.


If the added range intersects with any selection in the collection, an exception is thrown.


View Example

document.LoadDocument("SelectionCollection.docx", DocumentFormat.OpenXml)
Dim startPos As Integer = document.Tables(0).FirstRow.FirstCell.ContentRange.Start.ToInt()
Dim endPos As Integer = document.Tables(0).LastRow.LastCell.ContentRange.End.ToInt() + 1
Dim range1 As DocumentRange = document.CreateRange(startPos, endPos - startPos)

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(DocumentRange) method.


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