L
Larry
Hi,
I need to prevent a user from moving away from a DataGridView if it contains
invalid data.
Some specifics: The user should be able to move within the specific grid,
but not move to any other control on the form (including any other grid on
the form). I have tried a number of methods, for example:
1) From the Leave event of the grid: Set focus back to the grid (with and
without also calling BeginEdit)
2) From the RowValidating, set cancel = true if invalid data
3) From CellValidating, set cancel = true if invalid data
None of the above prevents the user from leaving the grid.
I could get it to work by trapping the Enter event on all other controls on
the form and setting focus back to the grid in question as needed from
there, but there must be a better way than that.
Does anyone know of a cleaner method to accomplish this?
Thanks,
Larry
I need to prevent a user from moving away from a DataGridView if it contains
invalid data.
Some specifics: The user should be able to move within the specific grid,
but not move to any other control on the form (including any other grid on
the form). I have tried a number of methods, for example:
1) From the Leave event of the grid: Set focus back to the grid (with and
without also calling BeginEdit)
2) From the RowValidating, set cancel = true if invalid data
3) From CellValidating, set cancel = true if invalid data
None of the above prevents the user from leaving the grid.
I could get it to work by trapping the Enter event on all other controls on
the form and setting focus back to the grid in question as needed from
there, but there must be a better way than that.
Does anyone know of a cleaner method to accomplish this?
Thanks,
Larry