Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

Formatting.BeginUpdate() Method

Locks the Formatting object by preventing visual updates until the EndUpdate method is called.

Namespace: DevExpress.Spreadsheet

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

Declaration

void BeginUpdate()

Remarks

The BeginUpdate and EndUpdate methods allow you to avoid flickering while performing batch modifications to the Formatting‘s settings. Once the BeginUpdate method has been called, modifying the Formatting‘s settings does not result in immediate repainting. So, multiple modifications can be made to the object without a major impact on performance or screen flickering. After all the desired operations have been finished, call the EndUpdate method.

The BeginUpdate and EndUpdate methods use an internal counter to implement the update functionality. The counter’s initial value is 0. Visual updates are forbidden if the counter’s value is greater than 0, and the updates are enabled if the counter’s value is 0. The BeginUpdate method increments the counter. The EndUpdate method decrements the counter. If the counter’s new value is 0, an immediate visual update occurs. Each call to BeginUpdate must be paired with a call to EndUpdate. To ensure that EndUpdate is always called even if an exception occurs, use the try…finally statement.

Example

  1. Use a style‘s index or name to obtain it from the Workbook.Styles collection.

  2. To change the style’s format attributes, modify the Style object’s properties within the Formatting.BeginUpdate - Formatting.EndUpdate method calls.

// Access a style you want to modify.
Style customStyle = workbook.Styles["Custom Style"];

// Change the style's format characteristics.
customStyle.BeginUpdate();
try {
    customStyle.Fill.BackgroundColor = Color.Gold;
    // ...
} finally {
    customStyle.EndUpdate();
}
See Also