Datagridview rowvalidating e cancel
Of course if there is an issue I Cancel the validation and the row is not committed.This all works fine when the user is editing and adding rows through UI interaction, but creates a problem when the Data Source is set.If a user has altered his assignments in dgd Eligible Files (checked/unchecked one/more rows) without clicking the Save button at form-bottom, and then clicks another row in dgd Applications, I currently use dgd Applications_Row Validating to pop a messagebox and verify that the user wants to proceed to the newly-selected application/row without saving changes. Row Validating and the user chooses "Yes" to continue (abandoning changes in dgd Eligible Files and going to the new row in dgd Applications), dgd Applications_Mouse Click does not get executed and nothing changes in dgd Eligble Files. When I put break points in both the Row Validating and Mouse Click event handlers, I never see Mouse Click execute - I only see Row Validating.
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.
The issue appears to be that Cell Formatting is not called when the DGV updates it's internal list and builds the rows, or at least it's not called before the validating event is fired.