Skip to main content

ColumnView.PopulateColumns(DataTable) Method

Creates columns for all the fields of the specified DataTable.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid


public void PopulateColumns(
    DataTable dataTable


Name Type Description
dataTable DataTable

A DataTable object representing a data table whose fields will provide data for the created columns.


This method clears the column collection and creates columns for visible fields within the specified data table. The GridColumn.FieldName property of each column is set to the respective bound field’s name. The GridColumn.VisibleIndex property is set to the bound field’s position within the data table.

Unlike the PopulateColumns method, which has no parameters, the current overload does not create grid columns for the System.Data.DataColumn objects that have the ColumnMapping property set to MappingType.Hidden. So, you can set this property for specific DataColumn objects to MappingType.Hidden to prevent them from being added to the grid control.

The PopulateColumns method, which has no parameters, cannot be used to create columns for detail pattern Views. If you need to populate pattern Views with columns, you need to use the method overloads that take appropriate parameters. If the pattern View is bound to a DataTable, then use the PopulateColumns method that takes a DataTable parameter. Similarly, if the pattern View is bound to a list (IXtraList or ITypedList), call PopulateColumns with a list parameter.

See Also