Datagridview cellvalidating not firing
I'm Developing a Windows Forms application with a datagridview bound to a datasource.In the process of validating some cell values the Row Validating Event does not fire when navagation moves off the row. However, if i change a cell value, Tab back to the left to another cell on the same row, then use the mouse to click on a Previous row above the changed row..... Example:: A B C D 1 x x x x 2 x x x x 3 x x x x If I change the value in C2, then backtab (or mouse click) back to B2, Then mouse click on any cell in row 1, the Row Validation Event does not fire and thus the changed value in C2 does not get evaluated. I am using Cell Validating but if one cell is dependant on another I cannot navagate away from the invalid cell to change the parent cell controlling the validation logic.What's the best place to implement validation logic code and conditional formatting code for a Data Grid View?In a lot of books and articles that I've read on this control, it seems to suggest that the appropriate event to handle for this is the Cell Validating one. However, this event triggers a bit too often for my tastes and I'm not sure it is required.What if someone is able to make a selection without a click event?There seems to be a non-zero percent chance that this might fire incorrectly in some unforeseen situation.Now, since so many books use the Cell Validating event, I wonder if there is not any gotcha (in display for example) with using the Cell Value Changed?I understand that the impact in performance should be irrelevant when using simple validation and conditional highlighting rules but I would as much prefer it not to run useless code everytime the user moves to another cell if it can be avoided.
I'd like the user to have the option of typing in the product ID or clicking a "Button" in the next column which would display another Gridview (like a Pop-Up) and allow the customer to select the product ID.For example, this event triggers everytimes the users switches to another row.On the other hand, the Cell Value Changed event seems to trigger only when the value of the cell changes, which means the validation code runs only when the value changes and not everytime a user changes cells.When you click a Check Box in a Data Grid View Check Box Column, the check marker will update immediately, but Cell Value Changed event on the Data Grid View will not fire until the user happens to click elsewhere and the cell has lost focus. Well, the Data Grid View thinks it’s a little preemptive to go declaring that the cell value has changed while you are still selected on it.This makes more sense when we think about a Text Box column.
In my case, Cell Value Changed has done what I wanted/needed.