[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
   [Expand]Product Information
    Product Structure
    Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
    Data Grouping
   [Expand]Pivot Tables
   [Expand]Charts and Graphics
   [Expand]Mail Merge
    Operation Restrictions
    Find and Replace
   [Expand]Visual Elements
   [Expand]Keyboard Shortcuts
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Data Validation

This document introduces the Data Validation concept and demonstrates how use the Data Validation API to manage data validation rules in a worksheet.

Expanded Data Validation Overview

Data validation ensures that a cell only accepts valid data. When users enter invalid data, a message can be displayed that explains why the value is invalid and/or how to correct the error.

The SpreadsheetControl provides the Data Tools command group located on the Data Ribbon tab, to invoke a Data Validation Dialog and to identify cells with invalid data by displaying a red circle around them.

When a user attempts to enter a value that is not correct according to validation rules, an alert is shown. Alert text is specified with the XtraSpreadsheetStringId.Msg_DataValidationFailed enumeration member so it can be easily localized, as described in the Localization topic.

You can also provide a custom message that explains what data can be entered in a cell, and a custom error dialog that appears when incorrect data is entered.

Expanded Data Validation API

The DataValidation interface provides information describing the data validation rule - the DataValidation.Range in which the rule is in effect, the DataValidation.ValidationType and other options which can be used while validating data.

Data validation rules in a worksheet are contained in the DataValidationCollection collection which is accessible via the Worksheet.DataValidations property.

To add a new data validation rule, use the DataValidationCollection.Add method of the collection. To cancel a particular rule, remove it from the collection. To remove all data validation rules, clear the collection.

Use the DataValidationCollection.GetDataValidation method to retrieve data validation rules for the specified cell. The DataValidationCollection.GetDataValidations method obtains data validation entries for cells in the specified range or that meet certain criteria.

Expanded Data Validation Common Tasks


API Members

User Interface

Restrict data to predefined items in a list.


Restrict numbers outside a specified range.




Restrict dates and times outside a certain time frame.



Limit the number of text characters.



Validate data based on formulas or values in other cells.


Create a message that explains what data can be entered in a cell.




Create a message that appears when the end-user types incorrect data.





Display or hide circles around invalid data.

The SpreadsheetControl circles only first 255 invalid cells,

other invalid entries are ignored.



Retrieve cells that do not meet the data validation criteria.


Check whether the cell contains valid data.


The code snippet below illustrates how to create and apply different validation criteria to worksheet cells using Data Validation API.


The maximum length of a list used to specify the DataValidationType.List validation type or a custom validation criteria is 255 characters. When a list or criteria exceeds this value, an InvalidOperationException is thrown.

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