GridColumn.UnboundType Property

Gets or sets whether the column is unbound, and the type of data the unbound column stores.

Namespace: DevExpress.XamarinForms.DataGrid

Assembly: DevExpress.XamarinForms.Grid.dll

Declaration

public UnboundColumnType UnboundType { get; set; }

Property Value

Type Description
UnboundColumnType

A value that specifies the data type and binding mode of the column.

Remarks

If the column's UnboundType property is set to Bound, it's assumed that this column stores values from a data source field that the column's FieldName property specifies. Otherwise, the column is unbound and it displays custom values.

To create an unbound column in the grid, do the following.

  1. Add a column object that corresponds to the type of data the column should display to the DataGridView.Columns collection.
  2. Set the column's FieldName property to a unique string that matches neither other columns' field names, nor any field name in the grid's underlying data source.
  3. Specify the UnboundType property according to the data type the column should display. For example, use the UnboundColumnType.Integer value if the column is supposed to display integer values.

To populate an unbound column with data, do one of the following.

You can also use the GridColumn.IsUnbound property to obtain whether a column is unbound.

Examples

Assume that the DataGridView instance is bound to a collection of orders. An order has the Product.Name, Product.UnitPrice and Quantity fields. This example shows how to add an unbound column (Total) to the grid to calculate each order amount according to the expression: UnitPrice*Quantity.

Implement logic to calculate column values in one of the following ways:

<dxg:DataGridView x:Name="grid" ItemsSource="{Binding Orders}">
    <dxg:DataGridView.Columns>
        <dxg:TextColumn FieldName="Product.Name" Caption="Product" Width="170" />
        <dxg:NumberColumn FieldName="Product.UnitPrice" Caption="Price" DisplayFormat="C0"/>
        <dxg:NumberColumn FieldName="Quantity"/>
        <dxg:NumberColumn FieldName="Total" UnboundType="Integer"
                          UnboundExpression="[Quantity] * [Product.UnitPrice]" 
                          IsReadOnly="True" DisplayFormat="C0"/>
    </dxg:DataGridView.Columns>
</dxg:DataGridView>
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding Orders}" CustomUnboundColumnData="Grid_CustomUnboundColumnData">
    <dxg:DataGridView.Columns>
        <dxg:TextColumn FieldName="Product.Name" Caption="Product" Width="170" />
        <dxg:NumberColumn FieldName="Product.UnitPrice" Caption="Price" DisplayFormat="C0"/>
        <dxg:NumberColumn FieldName="Quantity"/>
        <dxg:NumberColumn FieldName="Total" UnboundType="Integer"
                          IsReadOnly="True" DisplayFormat="C0"/>
    </dxg:DataGridView.Columns>
</dxg:DataGridView>
See Also