Start Datagridview cellvalidating cancel

Datagridview cellvalidating cancel

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.

Hi there, I have a question regarding datagridview, I add data to the datagridview in an interface and all the validation for the datagridview cell is in the datagridview cell validating event for the datagridview.

I display the data of the is datagridview in another interface and make the cells read-only. But the thing is when I click on a row that data was added previously and press the Add new row the cell validating event is triggered.

However, this event is fired every time the user leaves the cell, regardless of whether or not it has changed.

Something there is causing the cell validating event to fire. [Edit] The validating event is firing because focus is being moved from the DGV to the button.

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.

So my question is how can I have both validation and the ability to cancel edit of the datagridview row?