How to: Display Unbound Data
- 2 minutes to read
This example shows how to add an unbound column to the DXGrid control. This column should display the total price, calculated as follows: UnitPrice * UnitsOnOrder.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-create-unbound-columns-e1503.
<Window x:Class="DXGrid_UnboundColumns.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
Title="Window1"
Height="300"
Width="552">
<Grid>
<dxg:GridControl x:Name="grid" CustomUnboundColumnData="grid_CustomUnboundColumnData">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="ProductName" />
<dxg:GridColumn FieldName="UnitPrice">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings DisplayFormat="c2" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn FieldName="UnitsOnOrder" />
<dxg:GridColumn FieldName="Total" UnboundType="Boolean" ReadOnly="True">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings DisplayFormat="c2" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True"/>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>