ColumnView.Columns Property

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

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[Browsable(false)]
[XtraSerializableProperty(XtraSerializationVisibility.Collection, true, true, true, 0, XtraSerializationFlags.DefaultValue)]
[XtraSerializablePropertyId(2)]
public virtual GridColumnCollection Columns { get; }
<Browsable(False)>
<XtraSerializableProperty(XtraSerializationVisibility.Collection, True, True, True, 0, XtraSerializationFlags.DefaultValue)>
<XtraSerializablePropertyId(2)>
Public Overridable ReadOnly Property Columns As GridColumnCollection

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.

Examples

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;
See Also