windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-dcc6c2f2.md
Prevents visual and internal data updates until the BaseView.EndDataUpdate method is called.
Namespace : DevExpress.XtraGrid.Views.Base
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public override void BeginDataUpdate()
Public Overrides Sub BeginDataUpdate
If a sequence of actions which affects the View’s appearance needs to be performed, the code should be enclosed between calls to the BaseView.BeginUpdate and BaseView.EndUpdate methods. These methods allow the View to be locked, so that updates to the visual controls don’t occur when multiple changes are performed in sequence.
However, the BeginUpdate and EndUpdate methods do not prevent internal data updates. To prevent internal data updates, use the BeginDataUpdate and BaseView.EndDataUpdate methods. These allow improved grid control performance when performing a sequence of any of the following operations:
If the code that performs a sequence of any of these operations is wrapped with the BeginDataUpdate and EndDataUpdate methods, the View will perform only a single data update, reflecting all changes made, after the EndDataUpdate method is called.
The BeginDataUpdate and EndDataUpdate methods call the BeginUpdate and EndUpdate methods internally. This prevents the View from being updated visually.
When Grid Control is bound to a data source implementing the IBindingList interface. It automatically subscribes to the IBindingList.ListChanged event. This allows the grid to respond to changes made on the data source level. The BeginDataUpdate method temporarily unsubscribes the grid control from this event. The EndDataUpdate method, when called, subscribes the grid control to this event once again.
Do not add columns to the data source between BeginDataUpdate and EndDataUpdate method calls, as the grid control will not properly respond to these changes. This action may also raise exceptions. In addition, do not reassign a data source between BeginDataUpdate and EndDataUpdate method calls.
Note
Do not call the BeginDataUpdate and EndDataUpdate methods in master-detail mode if any detail is currently open, as this can cause some painting artifacts.
Please refer to the Batch Modifications Overview topic, for additional information.
The ColumnView.BeginSort and ColumnView.EndSort methods are equivalent to the BeginDataUpdate and BaseView.EndDataUpdate methods.
The following example sorts data by two columns in a Grid View. The code is enclosed within calls to the ColumnView.BeginDataUpdate and BaseView.EndDataUpdate methods. This speeds up performance by sorting the data only once, after the BaseView.EndDataUpdate method is called.
gridView1.BeginDataUpdate();
try {
gridView1.ClearSorting();
gridView1.Columns["Trademark"].SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
gridView1.Columns["Model"].SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
}
finally {
gridView1.EndDataUpdate();
}
gridView1.BeginDataUpdate()
Try
gridView1.ClearSorting()
gridView1.Columns("Trademark").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
gridView1.Columns("Model").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
Finally
gridView1.EndDataUpdate()
End Try
The following code snippets (auto-collected from DevExpress Examples) contain references to the BeginDataUpdate() 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-grid-display-editors-in-columns-headers/CS/WindowsApplication1/Form1.cs#L48
{
gridView1.BeginDataUpdate();
for (int i = 0; i < gridView1.DataRowCount; i++)
winforms-grid-customize-filter-criteria-before-apply/CS/FilterEvent/Form1.cs#L35
CriteriaOperator filter = this.GridView.ActiveFilterCriteria;
this.GridView.BeginDataUpdate();
try {
winforms-grid-display-editors-in-columns-headers/VB/Form1.vb#L46
Try
gridView1.BeginDataUpdate()
For i As Integer = 0 To gridView1.DataRowCount - 1
winforms-grid-customize-filter-criteria-before-apply/VB/FilterEvent/Form1.vb#L32
Dim filter As CriteriaOperator = GridView.ActiveFilterCriteria
GridView.BeginDataUpdate()
Try
See Also