Skip to main content
A newer version of this page is available. .

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.v19.2.dll

Declaration

[DXCategory("Data")]
[DefaultValue("")]
[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.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
columnExtPrice.UnboundExpression = "[Quantity] * [UnitPrice] * (1 - [Discount])";
gridView1.Columns.Add(columnExtPrice);
columnExtPrice.VisibleIndex = 0;

The following code snippets (auto-collected from DevExpress Examples) contain references to the UnboundExpression property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also