Document.Selections Property
Retrieves a collection of selections in the document.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v25.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
Declaration
Property Value
| Type | Description |
|---|---|
| SelectionCollection | A SelectionCollection object that contains ranges selected in the document. |
Remarks
The SelectionCollection contains all ranges selected in the document. To add an item to the collection, use the SelectionCollection.Add method.
Use the SelectionCollection.RemoveAt method to unselect previously selected range.
To unselect an arbitrary range, use the SelectionCollection.Unselect method.
Example
The code sample below shows how to select a cell content:
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
static void SelectSingleRange(Document document) {
document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.Docx);
int startPos = 80;
int endPos = document.Tables[0].Rows[1].LastCell.ContentRange.Start.ToInt();
DocumentRange myRange = document.CreateRange(startPos, endPos - startPos);
document.Selections.Add(myRange);
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Selections property.
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.