in my WinForms app. i have master-detail DataGridViews. i have attached a RowValidating event handler to my detail grid to make some validation and calculations.
RowValidating fires whenever a detail record loses focus.
the problem is:
when i set focus on a detail record (for editing or whatever) , and then move focus to master grid by clicking on a record that is NOT the parent of THAT detail record, this is what happens:
first : RowValidating event for that detail record is fired, which is logical (because it lost focus).
then : RowValidating event for its parent record is fired, which is logical, too (because we moved focus to a new parent) .
and then : RowValiding event for detail record is fired AGAIN !!! RowIndex is the same index of the detail record which previously lost focus, BUT the actual details that are present in the detail grid now are details of the NEW parent (which we clicked on)! THIS IS NOT LOGICAL.
i have tried other events (CellLeave, RowLeave) and they act the same :
detail events are fired first for the detail row which lost focus,
then master events are fired for its parent,
then detail events are fired AGAIN, but for details of the new parent and RowIndex of the old detail record ...
WHY are detail events are fired twice? and why are they using RowIndex of the previous detail record ?
P.S. i downloaded a master-detail DGV demo, and tried the same events, and similar things happened.
DEMO:
Three Master-Details Related Grids on the Same Form[
^]