.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

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.v20.1.Core.dll


SubDocument BeginUpdateDocument()
Function BeginUpdateDocument As SubDocument


Type Description

A SubDocument instance allowing you to safely modify the document.


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.


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.End, "<-");
See Also