Skip to main content

GridColumnDataEventArgs.IsGetData Property

Indicates that you should provide data for the current cell of the unbound column in the event handler.

Namespace: DevExpress.XamarinForms.DataGrid

Assembly: DevExpress.XamarinForms.Grid.dll

NuGet Package: DevExpress.XamarinForms.Grid

Declaration

public bool IsGetData { get; }

Property Value

Type Description
Boolean

true, if the event occurs to provide data for the unbound columns’s cell; otherwise, false.

Remarks

If the IsGetData property returns true (and consequently the IsSetData property is set to false), supply data for the currently processed cell in the event handler. To do this, assign a required value (for example, it can be calculated based on values of other columns in the current row) to the event’s Value parameter. To identify the currently processed row and unbound column, use the RowHandle and Column properties.

If the IsGetData property is set to false (and consequently the IsSetData property is set to true), the Value parameter identifies the cell value that a user modified in the grid’s unbound column. You can save it to your data source in the event handler.

Example

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:

  • Use the GridColumn.UnboundExpression property:

    <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>
    
  • Handle the DataGridView.CustomUnboundColumnData event:

    <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="Decimal"
                              IsReadOnly="True" DisplayFormat="C0"/>
        </dxg:DataGridView.Columns>
    </dxg:DataGridView>
    
    // Returns the total for a specific row.
    decimal getTotalValue(DataGridView grid, int rowHandle) {
        decimal unitPrice = Convert.ToDecimal(grid.GetCellValue(rowHandle, "Product.UnitPrice"));
        decimal quantity = Convert.ToDecimal(grid.GetCellValue(rowHandle, "Quantity"));
        return unitPrice * quantity;
    }
    
    // Provides data for the Total column.
    void Grid_CustomUnboundColumnData(object sender, GridColumnDataEventArgs e) {
        if (e.Column.FieldName == "Total" && e.IsGetData)
            e.Value = getTotalValue((DataGridView)sender, e.RowHandle);
    }
    
See Also