In native WinForm forms, a property called AutoValidate can be changed to EnableAllowFocusChange to allow users to continue to other controls if validation fails for an errorProvider.
I am trying to mimic this behavior with radGridView. Currently, users are unable to move onto other cells or rows, or other controls outside of the gridView until they input correct data into the cell.
I want to be able to allow the user to work on other things, add rows, edit cells on a new row or an existing row, etc without forcing them to input something just to get rid of the validation. Only at the end of the process would I loop through all controls and cells to see if an error exists, and remind the user before they can continue on.
This is so that the user doesn't put in erroneous data into the cell just so they can move on. For example, if they do not know what the account code is for an item, they would have to ask someone else and this may take some time. They should be able to work on other things on the form in the mean time.
I've tried cancelling the editor and calling EndEdit on the current active editor, but this isn't working. Users are still locked in on a cell if validation failed. How do I allow the user to get out of the cell even if an error exists?
See below on what I have tried:
if (e.Row is GridViewDataRowInfo)
{
if (detailValidation.IsEmptyInput(((string)e.Value), out errorMsg) || (!detailValidation.IsValidDecimalFormat(((string)e.Value), out errorMsg)))
{
e.ActiveEditor.EndEdit();
e.Cancel = true;
var test = e.ActiveEditor as RadTextBoxEditor;
currentCell.BackColor = Color.FromArgb(255, 221, 221);
((GridViewDataRowInfo)e.Row).ErrorText = errorMsg;
}
else
{
((GridViewDataRowInfo)e.Row).ErrorText = string.Empty;
}
}