When the validation fails, the editor is closed, but the user cannot change the current row in the grid until a valid cell value is entered.
In this situation the editor is not kept active when the validation fails and pressing the Esc key does not revert the changes as the editor is already closed.
Note that only the Cell Validating event can keep the editor active,when the validation fails and it does not allow the user to exit the cell until a valid value is filled.
However, pressing the Esc key in this situation will revert the initial value of the cell and it will close the editor. The Row Validating event has a slightly different behavior.
i have a Row Validating and Cell Validating event handlers on detail grid. further more, when i return back to THAT invalid cell, i discover that invalid value wasn't accepted, and cell has its old value.
this prevents user from leaving cell/row in details grid, EXCEPT in one case : when user inserts invalid data in details cell and directly moves focus to a master record which is not its parent, then user is not prevented from leaving that invalid cell !
another case: if i delete cell's value instead of inserting an invalid value, e.It looks like the "Row Validating" event DOESN'T fire if the grid is on a MODAL form but it DOES fire when the grid is on a NON-MODAL form. You can run in the immediate window by typing and seeing if you get the Row Validating popup from the handler: Module _Sandbox Test Sub Data Grid View Test Non Modal() Dim frm As New Form Dim dtable As New Data Table() dtable. If the value of a cell is not valid I'd like to warn the user with a message box and pressing This issue is explained in the following MSDN forums post: Data Grid View Row Validating = Index 4 does not have a value?Basically it appears to be a bug (or at least very unexpected behaviour) in the way the Data Grid View handles validation - the Message Box.I don't mind if the current row in the datagridview is lost when edit is canceled.EDIT: here is my validating methods: Here is how it looks when it happens, if I hit Escape key, the error message disappears, but when I try to click something else, Row Validation happens again and I back to this state: EDIT2: I use datatable as datasource for this datagridview. Row Validating, Address Of Row Validating Handler frm. The jist of the matter is that it seems that it is a BUG with Microsoft's implements of Data Grid View although they are refusing to fix it. ") End Sub End Module I can't tell you why this happens for you but I just did a test on one of our non-modal forms and the Row Validating event does fire when we close it. With a non-modal form the Row Validating does fire, but with a modal form it doesn't. Just found an answer: posted this question on a few sites so any change can be seen here or there.provides a convenient way to realize data validation before it is committed to the underlying data source.SOLUTION To achieve data validation prior the row is committed, you can handle the Cell Validating event, which is raised by the control when the current cell changes or when it goes out of edit mode.