Export (0) Print
Expand All
Expand Minimize

DataGrid.GenerateColumns Method

Generates columns for the specified properties of an object.

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

public static Collection<DataGridColumn> GenerateColumns(
	IItemProperties itemProperties
)

Parameters

itemProperties
Type: System.ComponentModel.IItemProperties

The properties of the object to be in the columns.

Return Value

Type: System.Collections.ObjectModel.Collection<DataGridColumn>
The collection of columns for the properties of the object.

ExceptionCondition
ArgumentNullException

itemProperties is null.

Each row in the data grid is bound to an object in the data source, and each column in the data grid is bound to a property of the data object. This method generates a collection that contains a column for each property.

Calling the GenerateColumns method provides the same functionality as setting the AutoGenerateColumns property to true. You will typically not call this method from your code.

This method is provided to enable designer tools to generate a collection of columns that can be edited by the user and then placed into the data grid. A designer tool can use the GenerateColumns method to return a collection of auto-generated columns. The designer tool can then provide a user interface to enable the user to edit the column types, and add or remove columns as necessary. The column collection can then be used to populate the Columns collection of the data grid by adding each column to the collection.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft