windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-300f9413.md
Locks the BaseView object by preventing visual updates of the object and its elements until the EndUpdate method is called.
Namespace : DevExpress.XtraGrid.Views.Base
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public virtual void BeginUpdate()
Public Overridable Sub BeginUpdate
The BeginUpdate and EndUpdate methods allow you to avoid flickering while performing batch modifications to the BaseView‘s settings. Once the BeginUpdate method has been called, modifying settings of the BaseView 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.
Tip
Do not change widths of banded Views’ columns inside the BeginUpdate \ EndUpdate block. Banded and Advanced Banded Grid Views use band widths to calculate widths of individual columns. For that reason, modified column widths are reset to their initial values when you call the EndUpdate method.
For detailed information on batch modifications , see the Batch Modifications topic.
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.
winforms-preserve-grid-state-on-refresh/CS/RefreshHelperClass.cs#L149
if(view.GroupedColumns.Count == 0) return;
view.BeginUpdate();
try {
winforms-grid-multiple-row-selection-web-style-checkboxes/CS/E1271/CheckMarkSelection.cs#L112
this._view = view;
view.BeginUpdate();
try {
winforms-grid-multi-cell-editing/CS/MultiSelectionEditingHelper.cs#L59
try {
view.BeginUpdate();
GridCell[] cells = view.GetSelectedCells();
create-a-federated-data-source-at-runtime/CS/FederationDataSourceExample/Form1.cs#L31
{
gridView1.BeginUpdate();
gridView1.Columns.Clear();
winforms-grid-add-radio-group-column/CS/Helper/GridRadioGroupColumnHelper.cs#L61
_GridView = gridView;
_GridView.BeginUpdate();
InitGridView();
winforms-preserve-grid-state-on-refresh/VB/RefreshHelperClass.vb#L158
If view.GroupedColumns.Count = 0 Then Return
view.BeginUpdate()
Try
winforms-grid-multiple-row-selection-web-style-checkboxes/VB/E1271/CheckMarkSelection.vb#L142
_view = view
view.BeginUpdate()
Try
winforms-grid-multi-cell-editing/VB/MultiSelectionEditingHelper.vb#L52
Try
view.BeginUpdate()
Dim cells As GridCell() = view.GetSelectedCells()
create-a-federated-data-source-at-runtime/VB/FederationDataSourceExample/Form1.vb#L28
Private Sub Properties_SelectedValueChanged(ByVal sender As Object, ByVal e As EventArgs)
gridView1.BeginUpdate()
gridView1.Columns.Clear()
winforms-grid-add-radio-group-column/VB/Helper/GridRadioGroupColumnHelper.vb#L63
_GridView = gridView
_GridView.BeginUpdate()
InitGridView()
See Also