DataGrid::AutoGeneratingColumn Event

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Occurs when an individual column is auto-generated.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public:
event EventHandler<DataGridAutoGeneratingColumnEventArgs^>^ AutoGeneratingColumn {
	void add(EventHandler<DataGridAutoGeneratingColumnEventArgs^>^ value);
	void remove(EventHandler<DataGridAutoGeneratingColumnEventArgs^>^ value);
}

You can change or cancel the column being created in the AutoGeneratingColumn event handler.

When all columns are auto-generated, the AutoGeneratedColumns event occurs.

The following example shows how to auto-generate columns and change the columns at creation time in the AutoGeneratingColumn event handler.

<!-- The DataGrid.DataContext is a DataTable that contains a list of customers.  The DataTable columns are  
     Title, FirstName, MiddleName, LastName, Suffix, CompanyName, EmailAddress, and Phone.-->
<DataGrid Name="DG1" ItemsSource="{Binding}" AutoGenerateColumns="True" AutoGeneratingColumn="DG1_AutoGeneratingColumn" />
No code example is currently available or this language may not be supported.

.NET Framework
Available since 4.0
Silverlight
Available since 2.0
Return to top
Show: