Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Add Unbound Data to a Data-Aware Control (XtraGrid)

  • 2 minutes to read

In most cases data-aware DevExpress .NET controls contain bound columns/fields that display data from bound data sources. In Grid Control, it is possible to add unbound columns/fields that can display arbitrary data. Unbound columns are not bound to any field in a data source. You can provide data for these fields by specifying a formula (string expression) used to evaluate values or by handling an event.

Tip

If you want to bind data without the currently existing ready-to-use source, use the UnboundSource component.

An unbound column/field must meet the following two requirements:

  • its FieldName property must be set to a unique value and not refer to any field in the control’s data source;
  • its UnboundDataType (or UnboundType) property must be set to the type of data the column/field is supposed to display. This property determines the default cell editor, value alignment, sorting and validity rules.

There is no difference between working with bound and unbound columns/fields. Unbound columns can be sorted, grouped and filtered in the same manner as bound columns. They also support summaries. When printing or exporting a control, the contents of unbound columns will be printed/exported as well.

#Providing data using expressions

For an unbound column/field, you can specify a formula (string expression) that will be used to evaluate values for this field. Use the column’s UnboundExpression property to specify an expression. At design time, you can invoke an Expression Editor via the Property Grid to build the expression. The Expressions section describes a syntax for creating formulas in code.

Expressions do not allow data entered by end-users to be saved. To create unbound columns and allow data entered by end-users to be saved, you need to provide data for unbound columns using an event (see below).

#Providing data via an event

A specific event fires for unbound columns/fields, allowing data to be provided. In addition, in the Grid Control, this event allows data entered by an end-user to be saved. In the Grid Control control, use the ColumnView.CustomUnboundColumnData event. This event is raised for each cell within unbound columns/fields.

See Also