All docs
V21.2
21.2
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

GridColumn.UnboundDataType Property

Allows you to make the column unbound, and specify the type of data it stores.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v21.2.dll

Declaration

[DXCategory("Data")]
public Type UnboundDataType { get; set; }

Property Value

Type Description
Type

The type of data to store in the unbound column.

Remarks

If the UnboundDataType property is not set to a valid data type (the property’s default value is System.Void), the current column is considered bound to a data source field (GridColumn.FieldName).

To switch a column to unbound mode, do the following:

  • Set the UnboundDataType property to the type of values this column should store.
  • Assign a unique field name to the GridColumn.FieldName property. The field name must not match the field name of another column nor the name of a data source field.
  • Use one of the following techniques to populate the unbound column with data:

See the following help topic for more information: Unbound Columns.

Example

In the following example, it is assumed that the Grid Control is bound to a table that contains the “Quantity”, “UnitPrice” and “Discount” columns. The code below adds an unbound column that calculates the total order amount according to the following expression: Quantity*UnitPrice*(1-Discount).

CD_UnboundColumns_example

using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;

private void Form1_Load(object sender, EventArgs e) {
    // ...
    gridControl1.ForceInitialize();

    // Create an unbound column.
    GridColumn unboundColumn = gridView1.Columns.AddField("Total");
    unboundColumn.VisibleIndex = gridView1.Columns.Count;
    unboundColumn.UnboundDataType = typeof(decimal);
    // Disable column edit operations.
    unboundColumn.OptionsColumn.AllowEdit = false;
    // Specify format settings.
    unboundColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
    unboundColumn.DisplayFormat.FormatString = "c";
    // Customize the appearance settings.
    unboundColumn.AppearanceCell.BackColor = Color.FromArgb(179, 226, 221);
}

// Return the total amount for a specific row.
decimal getTotalValue(GridView view, int listSourceRowIndex) {
    decimal unitPrice = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "UnitPrice"));
    decimal quantity = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Quantity"));
    decimal discount = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Discount"));
    return unitPrice * quantity * (1 - discount);
}

// Specify data for the Total column.
private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
   GridView view = sender as GridView;
   if (e.Column.FieldName == "Total" && e.IsGetData) e.Value = 
     getTotalValue(view, e.ListSourceRowIndex);
}
See Also