Skip to main content
A newer version of this page is available. .
.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.v19.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)

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

Note

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