Source
I am afraid it is difficult to determine the cause of the issue based
on the provided information. Generally, the ValidatingEditor
event
fires when an active editor is closed, and its value is changed.
The ValidateRow
event fires when a current row loses focus
, and
some of its values has been changed.
I suggest you to go through following links:
Validating Rows
Validating Editors
BaseView.ValidatingEditor Event
Check this example:
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraEditors.Controls;
private void gridView1_ValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e) {
GridView view = sender as GridView;
if(view.FocusedColumn.FieldName == "Discount") {
//Get the currently edited value
double discount = Convert.ToDouble(e.Value);
//Specify validation criteria
if(discount < 0) {
e.Valid = false;
e.ErrorText = "Enter a positive value";
}
if(discount > 0.2) {
e.Valid = false;
e.ErrorText = "Reduce the amount (20% is maximum)";
}
}
}
private void gridView1_InvalidValueException(object sender, InvalidValueExceptionEventArgs e) {
//Do not perform any default action
e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction;
//Show the message with the error text specified
MessageBox.Show(e.ErrorText);
}
Editor validation takes place when attempting to save the edit value (using the PostEditor
method) or when closing the active editor. First, the 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 your condition fails then set the e.Valid = false;
and the e.ErrorText = "ColumnSum must be <= 100";
and also handle the InvalidValueException
event of gridview.