Back to Devexpress

RichEditDocumentServer.EndUpdate() Method

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-f0a2cca7.md

latest5.4 KB
Original Source

RichEditDocumentServer.EndUpdate() Method

Unlocks the RichEditDocumentServer object.

Namespace : DevExpress.XtraRichEdit

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public void EndUpdate()
vb
Public Sub

Remarks

Enclose your code in the BeginUpdate() - EndUpdate method calls to improve performance when you apply multiple modifications to a document.

Each call to BeginUpdate() must be paired with the EndUpdate call. You can use the try…finally statement to ensure that EndUpdate is always called even if an exception occurs.

The following example shows how to use the BeginUpdate() - EndUpdate methods.

csharp
// Create a new RichEditDocumentServer instance.
RichEditDocumentServer richEditDocumentServer = new RichEditDocumentServer();

richEditDocumentServer.BeginUpdate();
try
{
    // Create a multiplication table.
    Table table = richEditDocumentServer.Document.Tables.Create(richEditDocumentServer.Document.Selection.Start, 8, 8, AutoFitBehaviorType.AutoFitToWindow);

    table.Borders.InsideHorizontalBorder.LineThickness = 1;
    table.Borders.InsideHorizontalBorder.LineStyle = BorderLineStyle.Double;
    table.Borders.InsideVerticalBorder.LineThickness = 1;
    table.Borders.InsideVerticalBorder.LineStyle = BorderLineStyle.Double;
    table.TableAlignment = TableRowAlignment.Center;

    table.ForEachCell((cell, rowIndex, columnIndex) =>
    {
        richEditDocumentServer.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} = {2}",
             columnIndex + 2, rowIndex + 2, (rowIndex + 2) * (columnIndex + 2)));
    });

}
finally
{
    richEditDocumentServer.EndUpdate();
}
vb
' Create a new RichEditDocumentServer instance.
Dim richEditDocumentServer As New RichEditDocumentServer()

richEditDocumentServer.BeginUpdate()
Try
    ' Create a multiplication table.
    Dim table As Table = richEditDocumentServer.Document.Tables.Create(richEditDocumentServer.Document.Selection.Start, 8, 8, AutoFitBehaviorType.AutoFitToWindow)

    table.Borders.InsideHorizontalBorder.LineThickness = 1
    table.Borders.InsideHorizontalBorder.LineStyle = BorderLineStyle.Double
    table.Borders.InsideVerticalBorder.LineThickness = 1
    table.Borders.InsideVerticalBorder.LineStyle = BorderLineStyle.Double
    table.TableAlignment = TableRowAlignment.Center

    table.ForEachCell(Sub(cell, rowIndex, columnIndex)
                           richServer.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} is {2}",
                                                        columnIndex + 2, rowIndex + 2, (rowIndex + 2) * (columnIndex + 2)))
                       End Sub)

Finally
    richEditDocumentServer.EndUpdate()
End Try

The following code snippets (auto-collected from DevExpress Examples) contain references to the EndUpdate() 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.

word-document-api-use-printablecomponentlink-to-print-document/CS/PrintingSystem/Form1.cs#L30

csharp
SetPrintOptions(srv);
srv.EndUpdate();
// Update fields

word-document-api-invoke-print-preview-dialog/VB/Form1.vb#L43

vb
_table.EndUpdate()
richServer.EndUpdate()
' Invoke the Print Preview dialog

word-document-api-use-printablecomponentlink-to-print-document/VB/PrintingSystem/Form1.vb#L30

vb
SetPrintOptions(srv)
srv.EndUpdate()
' Update fields

See Also

BeginUpdate()

IsUpdateLocked

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace