Skip to main content
A newer version of this page is available. .

GridRowValidationEventArgs Class

Provides data for the GridViewBase.ValidateRow event.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v17.2.Core.dll

Declaration

public class GridRowValidationEventArgs :
    ValidationEventArgs,
    IDataRowEventArgs

Remarks

Row validation is performed within the GridViewBase.ValidateRow event handler, when a row is about to lose focus. The processed row is returned by the GridRowValidationEventArgs.Row property. Its handle is returned by the GridRowValidationEventArgs.RowHandle property. After cell values have been obtained, you can verify whether the values meet your validity criteria. If the row fails validation, set the event’s ValidationEventArgs.IsValid parameter to false. Otherwise, leave the ValidationEventArgs.IsValid parameter set to true.

To learn more, see Row Validation.

Example

This example shows how to check the validity of data entered by end-users into a data row. The GridViewBase.ValidateRow and GridViewBase.InvalidRowException events are handled to validate the focused row’s data, and if it is invalid, prevent the row focus from being moved to another row until invalid values are corrected.

Since the Task class doesn’t support error notifications, it implements the IDXDataErrorInfo interface, providing two members to get error descriptions for the entire row and for individual cells (data source fields). This displays error icons within cells with invalid values. Pointing to such an error icon displays a tooltip with an error description.

Note

A complete sample project is available at: https://github.com/DevExpress-Examples/how-to-validate-data-rows-e1593

<Window x:Class="DXGrid_ValidateRow.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" Title="Window1" Height="300" Width="500">
    <Grid>
        <dxg:GridControl x:Name="grid">
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="TaskName" />
                <dxg:GridColumn FieldName="StartDate" />
                <dxg:GridColumn FieldName="EndDate" />
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" ValidateRow="TableView_ValidateRow" InvalidRowException="TableView_InvalidRowException" />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>

The following code snippets (auto-collected from DevExpress Examples) contain references to the GridRowValidationEventArgs class.

Note

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