Skip to main content

GridViewSettings.Columns Property

Provides access to a GridView’s column collection.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v23.1.dll

NuGet Package: DevExpress.Web.Mvc5


public MVCxGridViewColumnCollection Columns { get; }

Property Value

Type Description

A MVCxGridViewColumnCollection object that is a collection of columns.


The Columns property stores a collection of MVCxGridViewColumn objects that denote columns. It provides methods that allow you to add new and remove existing columns. Individual columns can be accessed using indexed notation.

Refer to the Columns topic for more information.


The following example illustrates how to use the GridViewSettings.Columns property.


For a full example, see the Grid View - Column Moving demo.

@Html.DevExpress().GridView(settings => {
    settings.Name = "grid";
    settings.Columns.Add("Category.CategoryName", MVCxGridViewColumnType.ComboBox);
    settings.Columns.Add("UnitPrice", MVCxGridViewColumnType.SpinEdit).PropertiesEdit.DisplayFormatString = "c";
    settings.Columns.Add("UnitsInStock", MVCxGridViewColumnType.SpinEdit);
    settings.Columns.Add(column => {
        column.FieldName = "Total";
        column.UnboundType = DevExpress.Data.UnboundColumnType.Integer;
        column.UnboundExpression = "UnitsInStock*UnitPrice";
        column.PropertiesEdit.DisplayFormatString = "c";
    settings.Columns.Add(column => {
        column.FieldName = "Discontinued";
        column.ColumnType = MVCxGridViewColumnType.CheckBox;
        column.Width = 80;
        column.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
See Also