This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.
GridControl supports bound and unbound columns. Bound columns obtain their data from data fields of the grid's underlining data source. Unbound columns are not bound to any field of the data source.
These columns must be populated with data manually.
Set this property to a value that identifies the type of data the column is supposed to display (Boolean, DateTime, Decimal, Integer, String or Object). Do not set the column's UnboundType property to UnboundColumnType.Bound, as this would identify the column as bound.
After a column is created, use one of the following two approaches to implement logic for populating a column with data.
Assign a formula (string expression) to the GridColumn.UnboundExpression property to automatically evaluate values for an unbound column. Expressions allow you to calculate values based on values of other columns. You can use constants, various functions and operators in expressions.
If the IsGetData parameter is set to true (and consequently the IsSetData parameter is set to false), the event handler should supply data for an unbound column. A value should be assigned to the GridColumnDataEventArgs.Value parameter according to the row currently being processed.
If the IsSetData parameter is set to true (and consequently the IsGetData parameter is set to false), the event has been fired as a result of data modifications within a grid. In this case, the Value parameter contains modified data and should be stored for further use.
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.
By default, data editing is enabled in unbound column cells. However, you may wish to prevent end-users from editing unbound columns. To make a column read-only, set the GridColumn.IsReadOnly property to true.
The GridControl cannot operate with only unbound columns. It must be bound to a data source using its GridControl.ItemsSource property.
Example - Implement Unbound Columns Using Expressions
This example shows how to create and customize grid columns for displaying and editing data of different types (text, numbers, dates and Boolean values). The specified collection contains columns bound to the data source fields (Product.Name, Product.UnitPrice, Quantity, Date and Shipped) and one unbound column (Total) displaying data values calculated according to a formula based on the values of other columns.
Assume that the GridControl instance is bound to a collection of orders. Each order has the "Product", "UnitPrice"and "Quantity" fields. The example below shows how to add an unbound column to the grid to display the amount of each order according to the expression: UnitPrice*Quantity.
We are updating the DevExpress product documentation website and this page is part of our new experience. During this transition period, product documentation remains available in our previous format at documentation.devexpress.com. Learn More...
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.