Skip to main content

GridColumnDataEventArgs.Value Property

Gets or sets the value of the cell currently being processed.

Namespace: DevExpress.Mobile.DataGrid

Assembly: DevExpress.Mobile.Grid.v18.2.dll

Declaration

public object Value { get; set; }

Property Value

Type Description
Object

An object specifying the value of the cell currently being processed.

Remarks

Important

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.

If the GridColumnDataEventArgs.IsGetData property is set to true (and consequently the GridColumnDataEventArgs.IsSetData property is set to false), a GridControl.CustomUnboundColumnData event handler should provide data for the cell currently being processed. You need to assign a required value (for example, it can be calculated based on values of other columns in the current row) to the Value property.

If the GridColumnDataEventArgs.IsGetData property is set to false (and consequently the GridColumnDataEventArgs.IsSetData property is set to true), a GridControl.CustomUnboundColumnData event handler should save the value of the Value property to the data source. In this case, the event is raised as a result of modifying the cell’s value via the grid.

The current unbound column is identified by the GridColumnDataEventArgs.Column property. The GridColumnDataEventArgs.RowData property can be used to identify the current row.

Example

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.

The result is displayed below:

GridControl_CustomUnboundColumnData

// Returns the total for a specific row.
decimal getTotalValue(GridControl 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 OnCustomUnboundColumnData(object sender, GridColumnDataEventArgs e) {
    if (e.Column.FieldName == "Total" && e.IsGetData)
        e.Value = getTotalValue (e.Source, e.RowData.RowHandle);
}

// Customizes the appearance settings.
void OnCustomizeCell(CustomizeCellEventArgs e) {
if (e.FieldName == "Total") {
        e.BackgroundColor = Color.FromRgb(247, 240, 213);
        e.Handled = true;
    }
}
See Also