Back to Devexpress

SubDocument.BeginUpdate() Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-a6dab073.md

latest6.2 KB
Original Source

SubDocument.BeginUpdate() Method

Locks the SubDocument object. Prevents visual updates until the EndUpdate method calls.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
void BeginUpdate()
vb
Sub BeginUpdate

Remarks

Use the BeginUpdate and EndUpdate methods to avoid flickering during batch modifications to the SubDocument‘s settings. After calling BeginUpdate, any changes to the SubDocument‘s settings do not cause immediate repainting. This allows multiple changes without affecting performance or causing screen flickering. Once you finish all desired changes, call EndUpdate.

The BeginUpdate and EndUpdate methods use an internal counter to manage updates. The counter starts at 0. When the counter is above 0, the system blocks visual updates. When the counter returns to 0, the system allows updates. The BeginUpdate method increments the counter. The EndUpdate method decrements the counter. If the counter reaches 0, an immediate visual update occurs.

Always pair each BeginUpdate call with an EndUpdate call. To ensure EndUpdate runs even if an exception occurs, use the try...finally statement.

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

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/FormattingActions.cs#L12

csharp
#region #FormatText
document.BeginUpdate();
document.AppendText("Normal\nFormatted\nNormal");

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/DocumentProperties.cs#L13

csharp
#region #StandardDocumentProperties
document.BeginUpdate();

word-document-api-examples/CS/CodeExamples/BookmarksAndHyperlinks.cs#L23

csharp
// Start to edit the document.
document.BeginUpdate();

winforms-richedit-table-of-contents-practical-guide/CS/Form1.cs#L28

csharp
private void btnStyles_Click(object sender, EventArgs e) {
    Document.BeginUpdate();
    ApplyStyles();

word-processing-table-of-contents-practical-guide/CS/Program.cs#L41

csharp
Document document = wordProcessor.Document;
document.BeginUpdate();
SearchForTOCEntries(document, delegate (DocumentPosition location, int level) {

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Formatting.vb#L12

vb
#Region "#FormatText"
            document.BeginUpdate()
            document.AppendText("Normal" & Global.Microsoft.VisualBasic.Constants.vbLf & "Formatted" & Global.Microsoft.VisualBasic.Constants.vbLf & "Normal")

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/FormattingActions.vb#L9

vb
' #Region "#FormatText"
            document.BeginUpdate()
            document.AppendText("Normal" & vbLf & "Formatted" & vbLf & "Normal")

word-document-api-examples/VB/CodeExamples/DocumentPropertiesActions.vb#L22

vb
' Start to edit the document.
document.BeginUpdate()
' Set the built-in document properties.

winforms-richedit-table-of-contents-practical-guide/VB/Form1.vb#L36

vb
Private Sub btnStyles_Click(ByVal sender As Object, ByVal e As EventArgs)
    Document.BeginUpdate()
    ApplyStyles()

word-processing-table-of-contents-practical-guide/VB/Program.vb#L37

vb
Dim document As Document = wordProcessor.Document
document.BeginUpdate()

See Also

SubDocument.EndUpdate

RichEditControl.EndUpdate

SubDocument Interface

SubDocument Members

DevExpress.XtraRichEdit.API.Native Namespace