Skip to main content

GridCellValidationEventArgs.CellValue Property

Gets the cell’s old valid value.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v23.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core


public object CellValue { get; }

Property Value

Type Description

An object that represents the cell’s old valid value.


When handling the GridColumn.Validate event, the cell’s curernt value isn’t saved to a data source until it is validated. The event parameter’s CellValue property returns the cell’s old valid value. The current value which is being validated is returned by the event parameter’s Value property.


This example shows how to validate the focused cell’s value. In this example, users cannot reduce the product’s price by more than 30% if the product is on discount.

DevExpress WPF | Grid Control - Cell Validation

View Example: How to Validate Cell Editors

<dxg:GridControl x:Name="grid">
        <dxg:GridColumn FieldName="ProductName">
                <dxe:TextEditSettings AllowNullInput="False" />
        <dxg:GridColumn FieldName="UnitPrice">
                <dxe:SpinEditSettings DisplayFormat="c2" />
        <dxg:GridColumn FieldName="Discontinued" />
        <dxg:TableView AutoWidth="True"
                       ValidateCell="OnValidateCell" />
void OnValidateCell(object sender, GridCellValidationEventArgs e) {
    if(e.Column.FieldName != nameof(Product.UnitPrice) || !((Product)e.Row).Discontinued)
    var cellValue = (double)e.CellValue;
    var discount = 100 - Convert.ToDouble(e.Value) / cellValue * 100;
    if(discount > 0 && discount <= 30)

    e.IsValid = false;
    e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical;
    e.ErrorContent = discount < 0
        ? $"The price cannot be greater than {cellValue}"
        : $"The discount cannot be greater than 30% ({cellValue * 0.7}). Please correct the price.";

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CellValue property.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also