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

DocumentRange.EndUpdateDocument(SubDocument) Method

Finalizes modifications of the document obtained via the document's range (e.g. via selection).

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v20.2.Core.dll


void EndUpdateDocument(
    SubDocument document
Sub EndUpdateDocument(
    document As SubDocument


Name Type Description
document SubDocument

A SubDocument instance obtained via the previously called DocumentRange.BeginUpdateDocument method.


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 EndUpdateDocument method implements this requirement.


The following code replaces the selected text with asterisks.

The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.

Private Shared Sub buttonCustomAction_ItemClick_Replace(ByVal sender As Object, ByVal e As ItemClickEventArgs)
    Dim richEdit As RichEditControl = TryCast(e.Item.Tag, RichEditControl)
    Dim range As DocumentRange = richEdit.Document.Selection
    Dim selLength As Integer = range.Length
    Dim s As New String("*"c, selLength)
    Dim doc As SubDocument = range.BeginUpdateDocument()
    doc.InsertSingleLineText(range.Start, s)
    Dim rangeToRemove As DocumentRange = doc.CreateRange(range.Start, selLength)
End Sub
See Also