J Cooper
J Cooper

Reputation: 17051

DataGridView: Bailing out of cell validation

I'm handling CellValidating and setting e.Cancel = true if the data in the cell is invalid. This almost gets me where I want to be, but the problem is if the user has some invalid data in the cell, the rest of the UI is essentially off-limits until they fix the error or press Esc.

Since pressing Esc might not be intuitive to certain users, they may find it frustrating that they can't e.g. click on the "Back" button I have on the form to leave the screen altogether. (In such a scenario, their change-in-progress should be discarded as if they had pressed Esc.)

Any ideas on how to achieve this? I do like that they aren't allowed to start editing other cells without fixing errors in their current cell, but I'd prefer they still be able to press the "Back"/"Cancel" buttons on the form.

Thanks in advance!

Upvotes: 2

Views: 2894

Answers (1)

keyboardP
keyboardP

Reputation: 69362

You could set the CausesValidation property to false.

Upvotes: 2

Related Questions