Back to Devexpress

ColumnViewOptionsBehavior.AutoPopulateColumns Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnviewoptionsbehavior-3eef19eb.md

latest5.7 KB
Original Source

ColumnViewOptionsBehavior.AutoPopulateColumns Property

Gets or sets whether to create columns automatically for all fields in the underlying data source (when binding the grid and if the View doesn’t contain any columns). When bound to a data source, the grid does not generate columns for properties of collection types.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AutoPopulateColumns { get; set; }
vb
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property AutoPopulateColumns As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true if the columns are created automatically when the View doesn’t contain any columns; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to AutoPopulateColumns
ColumnView

.OptionsBehavior .AutoPopulateColumns

|

Remarks

This property determines whether the BaseView.PopulateColumns method is called automatically when a data source is assigned to a View which doesn’t contain any columns. The BaseView.PopulateColumns method creates GridColumn objects for all the fields in the underlying data source and make these columns visible.

Set the AutoPopulateColumns property to false to prevent columns from being automatically created.

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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the AutoPopulateColumns property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-winforms-label-report-in-code/CS/Reporting_how-to-create-a-label-report-at-runtime-t473792/Form1.cs#L58

csharp
lookUpLabelProduct.Properties.DataSource = helper.GetLabelProducts().ToList();
lookUpLabelProduct.Properties.View.OptionsBehavior.AutoPopulateColumns = false;
lookUpLabelProduct.Properties.View.OptionsView.ShowColumnHeaders = false;

XDL_how-to-utilize-the-unboundsource-component-in-code-t474976/CS/UnboundDS-Code/Form1.cs#L11

csharp
InitializeComponent();
gridView1.OptionsBehavior.AutoPopulateColumns = false;
CreateDS();

reporting-winforms-label-report-in-code/VB/Reporting_how-to-create-a-label-report-at-runtime-t473792/Form1.vb#L50

vb
lookUpLabelProduct.Properties.DataSource = helper_Renamed.GetLabelProducts().ToList()
lookUpLabelProduct.Properties.View.OptionsBehavior.AutoPopulateColumns = False
lookUpLabelProduct.Properties.View.OptionsView.ShowColumnHeaders = False

XDL_how-to-utilize-the-unboundsource-component-in-code-t474976/VB/UnboundDS-Code/Form1.vb#L13

vb
InitializeComponent()
gridView1.OptionsBehavior.AutoPopulateColumns = False
CreateDS()

See Also

Columns

PopulateColumns()

ColumnViewOptionsBehavior Class

ColumnViewOptionsBehavior Members

DevExpress.XtraGrid.Views.Base Namespace