.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

SelectionCollection.Add(DocumentRange) Method

Adds a range to the collection of selections.

Namespace: DevExpress.XtraRichEdit.API.Native

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

Declaration

public void Add(
    DocumentRange range
)

Parameters

Name Type Description
range DocumentRange

A DocumentRange to add.

Remarks

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.

Important

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

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)
document.Selections.Add(range1)
See Also