Column Types

Column Types

A DataGrid control is formed by data bound columns. The control has the ability to automatically generate columns that are based on the structure of the data source. Auto-generation is the default behavior, but you can manipulate that behavior by using a Boolean property named AutoGenerateColumns. Set the property to false when you want the control to display only the columns you explicitly add to the Columns collection. Set it to true (the default) when you want the control to add as many columns as is required by the data source. The default algorithm for column generation creates simple data bound columns that use literal controls to display the contents of the corresponding data source fields. The DataGrid control supports additional column types that can render the column data so that it performs an action when clicked. The column types are explained in Table 2-2. Each is derived from the DataGridColumn class.