Winforms datagridview rowvalidating

However, the user may prefer to validate all the data cells in a row at once.

This scenario can be achieved by using the Row Validating event, which is fired when the user tries to change the current row (changing to another row or when the control loses focus).

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.

My problem is that when I click into it and then I change my mind and want to cancel edit of the current row these validating methods won't let me do that if it's the first row, it seems to work when there is already some valid rows, but when it's the first it won't let me change the focus to something else.

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

winforms datagridview rowvalidating-71winforms datagridview rowvalidating-45winforms datagridview rowvalidating-1

another case: if i delete cell's value instead of inserting an invalid value, e.

Show() causing validation on a row that no longer exists.

In my form I have a datagrid with a column that must be filled in every row.

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.

A small note is that I was overriding the On User Deleting Row event, which gets triggered when pressing Esc, which hid the very functionality I was looking for.

You must have an account to comment. Please register or login here!