DataGrid for WPF and Silverlight Overview > DataGrid Features > Defining Columns > Generating Columns |
By default, the C1DataGrid control generates columns automatically, based on the type of data, when you set the ItemsSource property. The generated columns are of type DataGridCheckBoxColumn for bound Boolean (and nullable Boolean) properties, and of type DataGridTextColumn for bound string data, DataGridComboBoxColumn for bound enum data, DataGridDateTimeColumn for bound date/time data, and DataGridNumericColumn for bound numeric data. Bound undefined data is displayed in a DataGridBoundColumn type column. If a property does not have a String or numeric value type, the generated text box columns are read-only and display the data object's ToString value.
You can prevent automatic column generation by setting the AutoGenerateColumns property to False. This is useful if you want to create and configure all columns explicitly. Alternatively, you can let the data grid generate columns, but handle the AutoGeneratingColumn event to customize columns after creation. To rearrange the display order of the columns, you can set the DisplayIndex property for individual columns.