GridControl.CustomUnboundColumnData Event
Enables data to be supplied to unbound columns.
Namespace: DevExpress.WinUI.Grid
Assembly: DevExpress.WinUI.Grid.v22.1.dll
NuGet Package: DevExpress.WinUI
Declaration
Event Data
The CustomUnboundColumnData event's data class is GridColumnDataEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Column | Gets the unbound column currently being processed. |
ListSourceRowIndex | Gets the index of the record in the data source to which the processed item corresponds. |
Row | Get a data row which contains the cell currently being processed. |
Source | Gets the grid control that raised the event. |
The event data class exposes the following methods:
Method | Description |
---|---|
GetListSourceFieldValue(Int32, String) | Returns the value of the specified cell within the specified item in the grid item source. |
GetListSourceFieldValue(String) | Returns the value of the specified cell within the processed item in the grid item source. |
Remarks
Unbound columns are not bound to any field in the data source. In most instances, data for unbound columns is obtained from a custom data source or is calculated based upon the values of bound columns. To provide data for unbound columns, handle the CustomUnboundColumnData event.
Example
The following code sample shows how to add an unbound column to the GridControl.
<Window ...
xmlns:dxg="using:DevExpress.WinUI.Grid">
<dxg:GridControl ItemsSource="{x:Bind ViewModel.Source}"
AutoGenerateColumns="False"
CustomUnboundColumnData="GridControl_CustomUnboundColumnData">
<dxg:GridControl.Columns>
<dxg:GridTextColumn FieldName="ProductName"/>
<dxg:GridSpinEditColumn FieldName="UnitPrice"/>
<dxg:GridTextColumn FieldName="Quantity"/>
<dxg:GridSpinEditColumn FieldName="Total" UnboundType="Decimal"/>
</dxg:GridControl.Columns>
</dxg:GridControl>
</Window>
void GridControl_CustomUnboundColumnData(object sender, DevExpress.WinUI.Grid.GridColumnDataEventArgs e) {
if(e.IsGetData) {
double unitPrice = Convert.ToDouble(e.GetListSourceFieldValue("UnitPrice"));
int quantity = Convert.ToInt32(e.GetListSourceFieldValue("Quantity"));
e.Value = unitPrice * quantity;
}
}
For more information, refer to the following help topic: Unbound Columns.