[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Collapse]Data Editing and Validation
     Add and Remove Rows
    [Expand]Modify Cell Values
    [Collapse]Input Validation
      Cell Validation
      Row Validation
      Error Notification
      Attributes-Based Validation
    [Expand]Clipboard Management
     Examples
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Cell Validation

The GridControl allows you to validate new cell values. The image below shows a GridControl with an invalid cell value:

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1592.

Follow the steps below to validate a cell's value:

Expanded Step 1. Handle a Validating Event

The GridControl provides the following events to validate cell values manually:

Note

The GridControl does not raise these events by default when changing cell values in code. Set the DataViewBase.AllowLeaveInvalidEditor property to true to enable raising events.

The code sample below shows how to validate the UnitPrice column's cell values:

Expanded Step 2. Validate a New Value

Use the following GridCellValidationEventArgs's properties to get cell values:

You can verify values according to validation rules after obtaining them. If a cell's value fails validation, set the ValidationEventArgs.IsValid property to false. In this case, an end-user cannot move focus to another cell until the cell's value is valid.

In the following code sample, the product's price cannot be reduced by over 30% if the product is discontinued:

Expanded Step 3. Indicate Errors

The GridControl displays an error icon within the cell if an edited cell's value is invalid:

Use the following GridCellValidationEventArgs's properties to customize the error indication:

The code sample below demonstrates how to show an error tooltip depending on the entered value:

Is this topic helpful?​​​​​​​