DocumentRange.BeginUpdateDocument() Method
Starts modifying the document obtained via the document’s range (e.g. via selection).
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v24.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
Declaration
Returns
Type | Description |
---|---|
SubDocument | A SubDocument instance allowing you to safely modify the document. |
Remarks
Use the DocumentRange.BeginUpdateDocument
- DocumentRange.EndUpdateDocument pair to modify the document obtained via selection (i.e. by using the Document.Selection property). In that case, it is very important to distinguish different parts of the document, such as header, footer or body. The BeginUpdateDocument method implements this requirement.
Example
This code sample demonstrates how to use and modify the selected part of the document. The selection can be located in the main part of the document, within the table, in the header, footer or in a text box. The DocumentRange.BeginUpdateDocument
method is a versatile method for accessing any document range, irrespective of its location. You are advised to obtain the selection using the Document.Selection property and use the SubDocument methods within the DocumentRange.BeginUpdateDocument
- DocumentRange.EndUpdateDocument method pair.
DocumentRange range = richEditControl1.Document.Selection;
SubDocument doc = range.BeginUpdateDocument();
string plainText = doc.GetText(range);
MessageBox.Show(plainText, "Selected Text");
doc.InsertText(range.Start,"->");
doc.InsertText(range.End, "<-");
range.EndUpdateDocument(doc);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the BeginUpdateDocument() 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.