Document.Selection Property
Gets or sets the selected range 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 |
---|---|
DocumentRange | A range that the selected text occupies. |
Remarks
Use the Document.Copy, Document.Cut and Document.Paste methods without parameters to work with selection in the document.
The DocumentRange.Start and DocumentRange.End properties allows you to obtain the selection’s start and end positions.
Use the SubDocument.GetText method to obtain the plain text contained in the selection.
When you select individual table cells, the Selection
property returns the last selected range. Use the Document.Selections property to obtain a collection of selections in the document. You can use the SelectionCollection to add new selection range or unselect previously selected range.
Example
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
static void SelectTextInRange(Document document) {
document.LoadDocument("Grimm.docx", DocumentFormat.OpenXml);
DocumentPosition myStart = document.CreatePosition(69);
DocumentRange myRange = document.CreateRange(myStart, 216);
document.Selection = myRange;
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Selection 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.