Skip to main content
A newer version of this page is available. .

ColumnView.Columns Property

Provides access to the collection of columns available for display within the View.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v19.1.dll

Declaration

[Browsable(false)]
[XtraSerializableProperty(XtraSerializationVisibility.Collection, true, true, true, 0, XtraSerializationFlags.DefaultValue)]
[XtraSerializablePropertyId(2)]
public virtual GridColumnCollection Columns { get; }

Property Value

Type Description
GridColumnCollection

A GridColumnCollection object representing a collection of available columns within the current View.

Remarks

The property stores all columns available for display in the current View. It allows you to add and delete columns using appropriate methods. You can also access individual columns using indexer notation or the bound field name as parameters. The addition of a column to the Columns collection does not make that column visible.

In the CardView and LayoutView, columns are displayed as card fields. In the GridView and its descendants, they are displayed as regular columns. In the WinExplorerView, which displays a list of items, columns correspond to item fields.

Each column in the GridView, CardView and WinExplorerView Views is a GridColumn object. In the AdvBandedGridView and BandedGridView Views, columns are BandedGridColumn objects. In the LayoutView, columns are LayoutViewColumn objects.

To learn how to make columns visible, see the Columns topic. All columns currently displayed within the View can be accessed via the ColumnView.VisibleColumns property.

To display columns from the Columns collection within the WinExplorerView, assign them to the predefined WinExplorerView columns from the WinExplorerView.ColumnSet property.

For more information on columns, see the Columns topic.

Example

The following example demonstrates how to create a column within a View, and assign a specific editor to it.

    using DevExpress.XtraGrid.Views.BandedGrid;
    using DevExpress.XtraEditors.Repository;
    //...
    BandedGridColumn col = advBandedGridView1.Columns.Add("Country") as BandedGridColumn;
    advBandedGridView1.Bands[0].Columns.Add(col);
    col.Visible = true;
    RepositoryItemLookUpEdit columnEditor = new RepositoryItemLookUpEdit();
    //customizing the column editor
    //...
    gridControl1.RepositoryItems.Add(columnEditor);
    col.ColumnEdit = columnEditor;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Columns 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.

See Also