Skip to main content

ColumnView.PopulateColumns(Object) Method

Creates columns for record fields in the specified data source (System.Data.DataTable, System.ComponentModel.ITypedList, System.Collections.IList, System.Collections.Generic.IList, DevExpress.XtraGrid.IXtraList, etc. ).

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public virtual void PopulateColumns(
    object list
)

Parameters

Name Type Description
list Object

The data source.

Remarks

This method creates columns in the ColumnView.Columns collection for record fields in the specified data source.

If a DataTable object is passed as the list parameter, this method redirects the call to the ColumnView.PopulateColumns overload that takes a DataTable parameter. Refer to this overload description for more information.

Before new columns are created, the PopulateColumns method first clears the column collection (ColumnView.Columns). The GridColumn.FieldName properties of the created columns are set to the names of respective data source record properties.

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 which 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 (IList, ITypedList, etc.), call the PopulateColumns method overload that takes a list parameter.

To create columns manually, use the methods provided by the ColumnView.Columns collection.

Note

A business object bound to a Grid Control may contain properties of collection types (e.g., of the List<> type). These properties instruct the Grid to enable master-detail mode (see Working with Master-Detail Relationships in Code). Columns corresponding to collection properties are not created in a master View.

See Also