A newer version of this page is available. Switch to the current version.

VGridControlBase.InvalidRecordException Event

Fires when a record fails validation or when it cannot be saved to the data source.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v18.2.dll


public event InvalidRecordExceptionEventHandler InvalidRecordException

Event Data

The InvalidRecordException event's data class is DevExpress.XtraVerticalGrid.Events.InvalidRecordExceptionEventArgs.


If a record was modified and is about to lose focus, the vertical grid raises the VGridControlBase.ValidateRecord event. You can handle this event to check the record’s data for validity. If the record fails validation or cannot be saved to the data source due to database restrictions, the InvalidRecordException is raised.

Handle the InvalidRecordException event to provide an appropriate response to invalid data being entered. The event parameter’s properties allow you to identify the record whose data failed validation, the exception that raised the event and to specify the error description. The actual response is specified by the ExceptionEventArgs.ExceptionMode parameter. You can display an error message box, discard the changes made, raise an exception or take no action.

For more information, see Validation.


Assume that the vertical grid contains two rows: “OrderDate” and “RequiredDate”. The value in the first row must be less than the value in the second one. So we need to validate their values in a record when it is about to be saved to the data source. For this purpose, the VGridControlBase.ValidateRecord event is handled.

If the record fails validation, we set errors for the rows with corresponding descriptions using the VGridControlBase.SetRowError method. The descriptions will be displayed when the mouse cursor hovers over the error icons.

The VGridControlBase.InvalidRecordException event is handled in order to suppress displaying the default error message box.

The following image shows a vertical grid after a record fails validation.


using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_ValidateRecord(object sender, ValidateRecordEventArgs e) {
   VGridControl vGrid = sender as VGridControl;
   // Get the value of the first row.
   DateTime value1 = Convert.ToDateTime(vGrid.GetCellValue(editorRow2, 
   // Get the value of the second row.
   DateTime value2 = Convert.ToDateTime(vGrid.GetCellValue(editorRow3, 
   if (value1 >= value2) {
      e.Valid = false;
      // Set errors with specific descriptions for the rows.
        "The value must be less than Required Date");
        "The value must be greater than Order Date");

private void vGridControl1_InvalidRecordException(object sender, 
InvalidRecordExceptionEventArgs e) {
   // Suppress displaying the error message box.
   e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction;
See Also