Skip to main content

Applying Data Annotations

DXGrid for Silverlight supports three DataAnnotations attributes, which can be applied to data class members. These attributes specify how data is displayed and whether data editing is allowed or not.

  • DisplayAttribute - Specifies a column's display settings (caption, tooltip, visibility, etc.). Its parameters are listed below.

    Order - specifies a column's position among visible columns;

    ShortName - specifies a column's caption;

    Description - specifies the text displayed within a column's tooltip;

    AutoGenerateField - specifies whether the grid creates a column for this field or not.

  • EditableAttribute - Specifies whether or not an end-user can invoke a column's in-place editor and edit cell values.
  • ReadOnlyAttribute - Specifies whether or not a column is read-only (an end-user can invoke its in-place editor and copy cell values; data editing is not allowed).

To use data annotation attributes, reference the System.ComponentModel.DataAnnotations assembly.

NOTE

The grid processes DisplayAttribute, if its columns are automatically generated after the grid has been bound to a data source. If the grid's GridControl.Columns collection is not empty, DisplayAttribute is ignored.

#Example