mobilecontrols-devexpress-dot-xamarinforms-dot-datagrid-dot-datagridview-72193e53.md
Occurs each time an individual column is generated automatically.
Namespace : DevExpress.XamarinForms.DataGrid
Assembly : DevExpress.XamarinForms.Grid.dll
NuGet Package : DevExpress.XamarinForms.Grid
public event AutoGeneratingColumnEventHandler AutoGeneratingColumn
The AutoGeneratingColumn event's data class is AutoGeneratingColumnEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| Column | Gets the column being generated automatically. |
The grid automatically creates columns based on the bound data source if you do not specify a collection of grid columns (DataGridView.Columns). You can use the DataGridView.AutoGenerateColumnsMode property to prevent columns from being automatically created or set another mode of auto generating columns.
This example shows how to use the AutoGeneratingColumn event to modify an auto-generated column at the time it is created, or cancel the generation of a column.
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding Employees}"
AutoGenerateColumnsMode="Auto"
AutoGeneratingColumn="Grid_AutoGeneratingColumn">
<!-- ... -->
</dxg:DataGridView>
using DevExpress.XamarinForms.DataGrid;
// ...
private void Grid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e) {
if (e.Column.FieldName == "Access")
e.Column.Caption = "Access Level";
if (e.Column.FieldName == "Photo")
e.Cancel = true;
}
See Also