[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Bind to JSON Data
    Bind to XPO Data
    Bind to Azure SQL Database
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Application Appearance and Skin Colors
  [Expand]Filtering UI Context
   Find Panel Syntax
  [Expand]Graphics Performance and High DPI
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML-inspired Text Formatting
  [Expand]Save and Restore Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  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 Annotation Attributes

DevExpress data-aware controls (GridControl, TreeList, VGridControl, PropertyGridControl and Data Layout Control) support Data Annotation Attributes provided by Microsoft. You can define these attributes when creating your data source in code. The grids and treelists that uses this data as their data source will recognize the attributes and automatically tweak their columns - re-arrange them, change their captions, format cell data, apply filters or validation etc. This means that using Data Annotation Attributes allows you to completely disregard the control designer, since none of the columns require manual customization.

For the Data Layout Control, even more complex UI customization is supported - certain data attributes not only allow you to apply display formats and validation rules, but to group layout items into specific groups and tabbed containers. See the Data Annotation Attributes in Data Layout Control topic to learn more.

To see a complete Data Annotation Attributes list, see this MSDN article. The tables below list the most common and frequently used attributes supported by the Grid Control and TreeList Control.

Expanded Data Display Attributes


Parameter (if any)


Code Sample



Specifies the column caption for the auto-generated column. This attribute has no effect on columns created at design-time. Column captions set by this attribute can be overridden by using the GridColumn.Caption property.


Specifies whether or not this column should be automatically generated by a GridControl.


Overrides the OptionsColumnFilter.AllowFilter property value for this column.


Specifies the display order for this column (see the GridColumn.VisibleIndex property).

Can be set to -1 to hide this column.


Assigns a tool-tip to this column. The GridColumn.ToolTip property overrides this attribute description.


Specifies whether this column can be edited (see the OptionsColumn.AllowEdit property).


Gets or sets whether this column is in read only mode (OptionsColumn.ReadOnly).



Specifies the display format for this column's records.


Specifies whether the current display format for this cell should remain visible when this cell is being edited.

Expanded Data Type Attributes


Parameter (if any)


Code Sample


Allows you to derive data annotation attributes from another class.


Specifies the type of this column's data.

Based on this info the grid control, applies the specific formatting and chooses the appropriate editor for column cells.


Allows you to replace numeric enumerator values with corresponding declarations.

Expanded Validation Attributes


Parameter (if any)


Code Sample


Specifies the maximum and minimum number of characters for string records within this column.


All numeric records of this column should lie in specific range, set by using this attribute.


If used, restricts an end-user leaving a cell within this column if this cell is currently empty.


Compares the field with another property. Entering values that differ from the compared column's value is restricted.

Also refer to the Data Binding topic to learn more about using Fluent API to add new and modify existing columns in Entity Framework Code First models.

Expanded Example

The solution in this example includes a DataSource file that has three classes that provide grid data - CompanyPublicInfo, CompanyPrivateInfo and Product. Properties for all three of them derive Data Annotation Attributes from the CompanyProductMetadata class by using the MetadataType attribute. End-users can use the editor at the top of the form to call one of the Get... methods that will populate the grid with sample data.


To work with Data Annotation Attributes, you need to reference the System.ComponentModel.DataAnnotations library in your solution.

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