A newer version of this page is available. Switch to the current version.

Unbound Columns

  • 4 minutes to read

Bound and Unbound Columns

The GridControl supports bound and unbound columns:

  • Bound columns obtain their data from data fields in the grid's data source.

    <dxg:GridControl x:Name="grid">
            <dxg:GridColumn FieldName="ProductName"/>
            <dxg:GridColumn FieldName="UnitPrice"/>
            <dxg:GridColumn FieldName="UnitsOnOrder"/>          
  • Unbound columns are not bound to any field in the data source.

    Handle the GridControl.CustomUnboundColumnData / TreeListView.CustomUnboundColumnData event to populate these columns.

    <dxg:GridControl x:Name="grid" CustomUnboundColumnData="grid_CustomUnboundColumnData">
            <!-- -->
            <dxg:GridColumn FieldName="Total" UnboundType="Boolean" >
    private void grid_CustomUnboundColumnData(object sender, GridColumnDataEventArgs e) {
        if (e.IsGetData) {
            int price = Convert.ToInt32(e.GetListSourceFieldValue("UnitPrice"));
            int unitsOnOrder = Convert.ToInt32(e.GetListSourceFieldValue("UnitsOnOrder"));
            e.Value = price * unitsOnOrder;

    GitHub Example: How to Create Unbound Columns

    This example shows how to add an unbound column to the GridControl. This column should display the total price, calculated as follows: UnitPrice * UnitsOnOrder.

    You can use the ColumnBase.UnboundExpression property to populate an unbound column. The Expressions section describes the syntax for creating expressions.

    <dxg:GridColumn FieldName="DiscountAmount"
                    UnboundExpression="Round([UnitPrice] * [Quantity] - [Total])">

An unbound column meets the following two requirements:

  • The ColumnBase.FieldName property must be set to a unique value, and not refer to any field in the grid's data source.
  • The ColumnBase.UnboundType property must be set to an appropriate value according to the type of data this column is supposed to display (Boolean, DateTime, Decimal, Integer, String or Object). This property determines an unbound column's default editor, used to represent its values. For example, if it is set to Boolean, a CheckEdit will be used by default. To replace the default editor, use the ColumnBase.EditSettings property.

The GridControl.CustomUnboundColumnData / TreeListView.CustomUnboundColumnData events are raised only for columns where both the FieldName and UnboundType properties are specified.

There is no difference between working with bound and unbound columns. You can sort, group, display summaries and filter unbound columns in the same manner as bound columns.

If unbound data is obtained from a custom data source, when adding a new row you should add a new entry to the custom data source that corresponds to the new record in the grid. Similarly, when a record is deleted, delete the corresponding entry in the custom data source. To receive notifications that a record has been added or removed, use the methods provided by a data source.

Unbound Column's Data

In most instances, data for unbound columns is obtained from a custom data source or is calculated based upon the values of bound columns.

Unbound data can be edited if it is retrieved from a custom data source. After an end-user has changed an unbound column's value, this value should then be saved back to the grid's data source. By default, data editing is enabled. To make an unbound column read-only, set its ColumnBase.ReadOnly property to true. You can also disable data editing by setting the ColumnBase.AllowEditing property to 'False'.

To provide data for unbound columns and save any changes made back to a custom data source, handle the GridControl.CustomUnboundColumnData event. Note that this event is raised only for unbound columns.