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
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
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-richedit-document-api-e5219
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)
Related GitHub Examples
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.