Applying Data Annotations
- 2 minutes to read
#Overview
The GridControl supports multiple Data Annotation Attributes that are used for customizing data classes, to specify how data is displayed from a data source, define validation rules, and set relationships between data classes.
To use data annotation attributes, reference the System.ComponentModel.DataAnnotations assembly. To use additional attributes for setting masks, reference the DevExpress.Mvvm.v24.2 assembly.
Note
Non-string IEnumerable properties are not automatically populated. To generate editors for such properties, use the [Display
#Smart Columns Generation
Set the DataControlBase.EnableSmartColumnsGeneration property to true to enable the Smart Columns Generation.
Below is a list of the Smart Columns Generation features.
Data Field | Generated Column’s Settings |
---|---|
Numeric (nullable numeric) data type | |
Boolean (nullable Boolean) data type | |
Decimal |
Text Text |
Enum data type |
Look |
Date or [Data | |
Numeric data type and [Data |
Text Text |
Date and [Data |
Text |
Date and [Data |
Text |
Date |
Text Text |
Time |
Text Text |
String data type and [Data | |
String data type and [Data | |
[Url] attribute or [Data | |
[Data | |
[Read | Column |
[Editable | Column |
[Display or [Hidden | Base |
[Display | Base |
[Display or [Display | Base |
[Display | The column is placed into the Grid |
In addition, the following attributes allow you to specify the editor’s mask settings: DateTimeMaskAttribute, NumericMaskAttribute, RegExMaskAttribute, RegularMaskAttribute, and SimpleMaskAttribute.