Skip to main content

VGridControlBase.ValidatingEditor Event

Enables you to perform manual validation of cell values.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v23.1.dll

NuGet Package: DevExpress.Win.VerticalGrid


public event BaseContainerValidateEditorEventHandler ValidatingEditor

Event Data

The ValidatingEditor event's data class is BaseContainerValidateEditorEventArgs. The following properties provide information specific to this event:

Property Description
ErrorText Gets or sets the error description.
Valid Gets or sets whether the value is valid.
Value Gets or sets the value being validated.


Editor validation takes place when attempting to save the edited value (using the VGridControlBase.PostEditor method) or when closing the active editor. The currently validated cell is identified by the VGridControlBase.FocusedRow and VGridControlBase.FocusedRecord properties.

First, automatic validation is performed. The editor determines whether it can accept the entered value. After the automatic validation has been performed, the ValidatingEditor event is raised. Handle this event to implement custom constraints on cell values.

If the entered value doesn’t match your custom criteria, set the event parameter’s BaseContainerValidateEditorEventArgs.Valid parameter to false. The value is specified by the BaseContainerValidateEditorEventArgs.Value property. The cell being edited can be identified using the vertical grid’s VGridControlBase.FocusedRow, VGridControlBase.FocusedRecord and VGridControlBase.FocusedRecordCellIndex properties.

If the BaseContainerValidateEditorEventArgs.Valid parameter’s value has been set to false, the edit value isn’t saved, and the cell remains focused so that end-users can correct it. Additionally, the cell displays an error icon (ErrorIcon) and the tooltip which contains the text specified by the BaseContainerValidateEditorEventArgs.ErrorText property. Note that the BaseContainerValidateEditorEventArgs.Valid parameter can initially be set to false. This takes place if the editor fails automatic validation.

The default event handling result (displaying an error icon and tooltip leaving the editor focus unchanged) can be overridden by handling the VGridControlBase.InvalidRecordException event.


The following example prohibits assignment of invalid values to “Department Budget” child rows. The cell’s value should be no greater than 100,000. The VGridControlBase.ValidatingEditor event is handled to check the entered value’s validity. The VGridControlBase.InvalidValueException event is handled to display an exception message box if an invalid value is assigned. In this instance, the VGridControlBase.HideEditor method is called to discard the changes made and destroy the cell’s editor.

using DevExpress.XtraVerticalGrid;
using DevExpress.XtraEditors.Controls;

private void vGridControl1_ValidatingEditor(object sender, 
BaseContainerValidateEditorEventArgs e) {
  VGridControl vGrid = sender as VGridControl;
  if (vGrid.FocusedRow.Name == "rowAnatomy" || 
      vGrid.FocusedRow.Name == "rowBusiness" ||
      vGrid.FocusedRow.Name == "rowDesign" || 
      vGrid.FocusedRow.Name == "History")
     if (Convert.ToInt32(e.Value) > 100000) e.Valid = false;

private void vGridControl1_InvalidValueException(object sender, 
InvalidValueExceptionEventArgs e) {
   VGridControl vGrid = sender as VGridControl;
   e.ExceptionMode = ExceptionMode.DisplayError;
   e.WindowCaption = "Input Error";
   e.ErrorText = "The value should be less than 100000";

   // Destroying the editor and discarding the wrong changes made within the edited cell
See Also