Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataControlBase.AutoGeneratingColumn Event

Occurs each time an individual column is auto-generated.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v24.2.Core.dll

NuGet Package: DevExpress.Wpf.Grid.Core

#Declaration

public event AutoGeneratingColumnEventHandler AutoGeneratingColumn

#Event Data

The AutoGeneratingColumn event's data class is DevExpress.Xpf.Grid.AutoGeneratingColumnEventArgs.

#Remarks

Use the AutoGeneratingColumn event to change or cancel an automatically generated column when it is created.

The following example prevents a grid from generating a column based on the IsSelected data field:

<dxg:GridControl AutoGenerateColumns="AddNew"
                 EnableSmartColumnsGeneration="True" 
                 AutoGeneratingColumn="grid_AutoGeneratingColumn"
                 ItemsSource="{Binding Items}">
    <!--...-->
</dxg:GridControl>
private void grid_AutoGeneratingColumn(object sender, DevExpress.Xpf.Grid.AutoGeneratingColumnEventArgs e) {
    if (e.Column.FieldName == "IsSelected") {
        e.Cancel = true;
    }
}
See Also