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

Performing Multiple Data Updates

  • 2 minutes to read

The GridControl refreshes its UI and internal state each time its data source collection is updated.

Depending on the size of your data source, the amount and frequency of updates, it may be useful to lock the GridControl and update it after all the data is updated.

Use the DataControlBase.BeginDataUpdate and DataControlBase.EndDataUpdate methods to prevent the control’s internal data updates:

  1. Call the BeginDataUpdate method. The GridControl stops reacting on data updates.
  2. Perform data updates.
  3. Call the EndDataUpdate method. The GridControl updates its UI to reflect all the changes.

Note

If a data source is modified from another thread (for example, using Parallel.ForEach), the grid cannot process these changes correctly, and an exception is thrown. To avoid possible issues, use one of the following approaches:

  • Use the Dispatcher.Invoke method to update the data source from the main thread
  • Enclose the changes within the BeginDataUpdate and EndDataUpdate method calls

Example

The code sample below demonstrates how to prevent GridControl from frequent updates during multiple data changes.

public void PerformUpdates() {
    gridControl.BeginDataUpdate();
    // Perform massive data updates...
    gridControl.EndDataUpdate();
}

Refer to the How to display data which is being updated on another thread (MVVM) GitHub example for information on how to call the GridControl’s BeginDataUpdate and EndDataUpdate methods in View Models.

See Also