Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Collapse]Data Editing
    [Expand]Edit Form
    [Collapse]Editing via Code
      Adding and Deleting Records
      Obtaining and Setting Cell Values
      Refreshing the GridControl
    [Expand]In-place Editors
    [Expand]Input Validation
    [Expand]New Item Row
     Tutorial: Add or Remove Rows
     Tutorial: Data Input Validation
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Refreshing the GridControl

It is possible to bind Grid Control to a data source that doesn't support change notifications. However, when you modify the data in such a data source, Grid Control doesn't receive any change notifications and therefore doesn't reflect the changes made to the data. In this case, to synchronize the grid control with the data in the data source you need to update the grid control manually. On the other hand, if the data source implements the System.ComponentModel.IBindingList interface the grid is always aware of any modifications to the data source. Also if you change any type of a bound data source using only the methods provided by Views, no manual updates are required. The Obtaining and Setting Cell Values document describes how to change values using the functionality provided by Views.

Expanded Refreshing the Grid Control

To refresh the grid control and synchronize the data it displays with information in the bound data source, call the GridControl.RefreshDataSource method. This will update all the currently visible Views. If grouping or sorting is applied to Views, the method re-sorts the data in the data source to reflect the grouping and sorting settings.

To update only a specific view, use the BaseView.RefreshData method.

The following code assumes that the grid control's data source is an array of Record objects. When changing the "Phone" field of the record, the GridControl.RefreshDataSource method is called to reflect the changes in the grid control.

The GridControl.RefreshDataSource method calls the Refresh method of the corresponding System.Windows.Forms.CurrencyManager object. This forces an update to the current grid control and all the controls bound to the same data source. For information on the CurrencyManager, see the CurrencyManager class and Windows Forms data providers topics in the MSDN Library.

You don't need to call the GridControl.RefreshDataSource method of the grid control to update it if they are bound to data sources that support change notifications (for instance, System.Data.DataView). Such data sources fire change events and thus the grid control is always synchronized with a bound data source.

Expanded Implementing Notification Behavior

The GridControl.RefreshDataSource method can take a while to execute, especially when grouping or sorting is applied to a View. If your data source doesn't support change notifications and you have to change data via the methods provided by the data source, consider implementing the System.ComponentModel.IBindingList interface. If the data source implements this interface, the grid control automatically subscribes to the ListChanged event and this ensures that it will receive appropriate change notifications when you add, delete, move or modify records.

Below is an example from the IBindingList tutorial. The IBindingList interface is implemented for the Records class which is a collection of Record objects. Whenever a new record is added, inserted or removed, the ListChanged event is raised, which provides details on the changes made. For this purpose the CollectionBase.OnInsertComplete and CollectionBase.OnRemoveComplete methods are overridden.

Each Record object is aware of its owner. When any property of a Record object is modified, the ListChanged event of its owner will also be fired.

If you assign a Records instance to the GridControl.DataSource, the grid control will automatically receive all change notifications when records are modified via the data source. The full code can be found in the IBindingList tutorial.

Expanded See Also

How would you rate this topic?​​​​​​​