Document.Selections Property
Retrieves a collection of selections in the document.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v24.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.OpenXml);
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);
}
See Also