As far as I can tell, the code on your site only helps with validating the data, not stopping the Row Leave event entirely.
- This posting is provided "as is" with no warranties and confers no rights.Jeffrey, Though I original thought that this would work, I have since realized that the Row Validation event does not trigger at a time which makes it feasible to stop a user from leaving a row when there is theoretically invalid data in the record.Thanks, Matt Jeffrey Tan[MSFT] wrote: Hi Matt, Thanks for your post.For Data Grid View, it has a Cell Validating and Row Validating events, these 2 event handlers take Data Grid View Cell Validating Event Args/Data Grid View Cell Cancel Event Args type paramters. We can set Cancel property to true to prohibit the user from selecting another row. Hope this helps Best regards, Jeffrey Tan Microsoft Online Partner Support Get Secure!Since you are already validating your fields, and throwing up the error message, set a switch for valid row.
Then, what you need is an event AFTER, all the row leaves, row enter, cell enter events.
- This posting is provided "as is" with no warranties and confers no rights. So we should check the leaving row and validate it, if not valid, we can set e. Hope this helps Best regards, Jeffrey Tan Microsoft Online Partner Support Get Secure!
Matt, I was having the same issue, and have found a work around (maybe not ideal, but it works).
If I try to create a new record, it triggers the validation event, sees that the First Name field on the new record is empty, and throws up my message box.
Is there any way to make solely use the information on the row it was leaving?
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).