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
    [Expand]Editing via Code
    [Expand]In-place Editors
    [Collapse]Input Validation
     [Collapse]ErrorInfo Support
       Internal ErrorInfo Support
       Implementing ErrorInfo Support for Data Sources
      Validating Editors
      Validating Rows
    [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

Implementing ErrorInfo Support for Data Sources

If the grid control is bound to a System.Data.DataView or System.Data.DataTable, you can set errors for any cell within any row using methods provided by the data source. To set an error for a particular cell, you can call the System.Data.DataRow.SetColumnError method of a specific DataRow object. The grid control will indicate such errors by displaying error icons () within cells with the descriptions displayed as tooltips.

To support error notifications for any cell and row for other data source types (IList, ITypedList, IListSource, IBindingList, etc), you should implement the IDXDataErrorInfo or System.ComponentModel.IDataErrorInfo interface for the objects representing records in your data source. This document gives you an example of implementing the IDataErrorInfo interface for a custom data source.

Note that the grid control provides methods to set errors for individual cells within the focused row and for the entire focused row. These methods can be applied regardless of the data source type. Usually you use these methods when validating the user's input via the BaseView.ValidateEditor and/or ColumnView.ValidateRow events. For more information, refer to the Internal ErrorInfo Support document.

Expanded Implementing the Error Notification Behavior

To bind a grid control to data created at runtime, you usually create two classes:

  • the class representing a data source; this implements one of interfaces (IList, IListSource, ITypedList, IBindingList) and provides access to the collection of records;
  • the class implementing a single record for a data source class.

If a data source supports error notifications, you are able to implement a validation procedure to verify data contained in the data source and, if invalid data is encountered, set errors for particular records and record's fields.

To support error notifications, the class encapsulating a single record must implement the System.ComponentModel.IDataErrorInfo interface. This allows two members to get error descriptions for the entire record and for individual record's properties (data source fields). If a record object implements the interface, the grid control will display error icons within cells for which errors were set via the data source. Pointing to such an error icon displays a tooltip with an error description.

 

The GridUnboundErrorNotification tutorial shows how to implement the System.ComponentModel.IDataErrorInfo interface for a custom data source.

The NoteInfo class represents a single record and provides the Day, Month, Year and NoteID fields displayed as columns in a grid control. This class implements the System.ComponentModel.IDataErrorInfo interface and also introduces methods managing errors. It provides the SetColumnError, GetColumnError methods and NoteError property to get and set error descriptions for individual properties (Day, Month, Year and NoteID) and the entire record.

To clear a specific error, one should set the error to an empty string.

 

The ProjectNotes class manages a collection of NoteInfo objects and this represents a data source for a grid control. This class supports change notifications by implementing the System.ComponentModel.IBindingList interface. When a new record is added or when record's properties and error descriptions are set, the IBindingList.ListChanged event is fired thus notifying the grid control that a particular record should be updated. You can refer to the Refreshing the GridControl document for details on implementing data change notifications.

 

Data is validated within a custom ValidateData procedure. This traverses all records and checks the validity of data. If a record refers to an invalid date, an error is set for this record and for the date column where an error is encountered. The grid will indicate the errors with error icons as shown in the image below. Pointing to an icon displays a descriptive tooltip.

See the GridUnboundErrorNotification tutorial for the complete code.

Expanded See Also

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