This documentation is archived and is not being maintained.
DataGrid::AutoGeneratingColumn Event
Visual Studio 2010
Occurs when an individual column is auto-generated.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public: event EventHandler<DataGridAutoGeneratingColumnEventArgs^>^ AutoGeneratingColumn { void add (EventHandler<DataGridAutoGeneratingColumnEventArgs^>^ value); void remove (EventHandler<DataGridAutoGeneratingColumnEventArgs^>^ value); }
<object AutoGeneratingColumn="EventHandler<DataGridAutoGeneratingColumnEventArgs>" .../>
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" />
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: