Skip to main content
A newer version of this page is available. .

LayoutControl.BeginUpdate() Method

Locks the LayoutControl object by preventing visual updates of the object and its elements until the EndUpdate method is called.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v20.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public void BeginUpdate()

Remarks

The BeginUpdate and EndUpdate methods allow you to avoid flickering while performing batch modifications to the LayoutControl‘s settings. Once the BeginUpdate method has been called, modifying settings of the LayoutControl and its elements does not cause an immediate visual update. So, multiple modifications can be made to the object and its elements 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.

Note

When you add multiple items to, or remove or hide them from the layout, do not execute this code within the BeginUpdate/EndUpdate block. The Layout Control needs to recalculate positions and bounds of affected items before you add, remove or hide the next item. All recalculations are locked within the BeginUpdate/EndUpdate block.

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.

See Also