Skip to main content

GridColumn.UnboundExpression Property

Gets or sets an expression that the unbound column uses to calculate its cell values. Columns with unbound expressions are non-editable.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v24.2.dll

Declaration

[DefaultValue("")]
[DXCategory("Data")]
[XtraSerializableProperty]
public string UnboundExpression { get; set; }

Property Value

Type Default Description
String String.Empty

A string that specifies an expression used to evaluate values for the current column.

Remarks

Unbound columns can be populated in two ways.

  • Specify the UnboundExpression and the column will automatically calculate its cell values. Users are unable to edit cell values if the parent column employs unbound expressions to calculate these values.

  • Handle the ColumnView.CustomUnboundColumnData event to provide custom cell values to a column. This approach leaves column cells editable.

At design time, click the ellipsis button (…) next to the UnboundExpression property in the Visual Studio Properties window to invoke the Expression Editor (see the figure below). This editor allows you to build unbound expressions from field names, operators, constants, and mathematical functions. If the GridColumn.ShowUnboundExpressionMenu option is enabled, users can use the same editor at runtime to edit this column’s expression.

ExpressionEditor

If you need to specify valid expressions in code, refer to the Expressions article for the expression syntax.

For more information about unbound columns, see Unbound Columns.

Online Video

WinForms Grid: Unbound Columns.

Example

The following code shows how to create an unbound column (Ext Price) and populate it with data using expressions. Data for this column is calculated according to the formula: [Quantity] * [UnitPrice] * (1 - [Discount]), which is set via the GridColumn.UnboundExpression property.

using DevExpress.XtraGrid.Columns;

GridColumn columnExtPrice = new GridColumn();
columnExtPrice.FieldName = "ExtPrice";
columnExtPrice.Caption = "Ext Price";
columnExtPrice.UnboundDataType = typeof(decimal);
columnExtPrice.UnboundExpression = "[Quantity] * [UnitPrice] * (1 - [Discount])";
gridView1.Columns.Add(columnExtPrice);
columnExtPrice.VisibleIndex = 0;
See Also