Click here to Skip to main content
14,697,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,
i have master-detail DataGridViews and a save button.
i have a RowValidating event handler on my detail DataGridView,
and a button Click event handler for the button.

when i add a new row to detail grid, and then immediately click the save button, i expect these handlers to be executed : RowValidating , ButtonClick
but that doesn't happen..

RowValidating handler gets executed, but button Click handler is never reached.
i commented out all code in my RowValidating handler, and the problem was still there...

i deleted RowValidating handler, and only then ( Click handler) was executed.

any idea what the problem could be?
i haven't posted any code, because the problem is there even if no code is written within the RowValidating handler
thanks in advance
Posted

1 solution

i have solved it like this :

i set CausesValidation Property of the save button to FALSE, so when the button is clicked immediately after changing a value in the grid, the RowValidating event is never fired. and to insure validation the the grid row, i just called this.Validate() method inside the buttonClick event handler. this method will fire validation events for the control which lost focus when the button was clicked.

in my case, when i edit a row in the grid, and click the button, the buttonClick is fired, and form.validate() is called, which in turn calls RowValidating on my lately modified grid row.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900