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.
How can I disable the cell validating event for the rows that was added before???thankxxxxxx There are two ways to manage unwanted execution of event handlers.Any solution is going to involve using an event that definitely will fire to stop the Data Grid View from thinking it’s in edit mode.This problem was also raised in a Stack Overflow Question which seemed to advocate for handling the method, thereby ensuring that the grid would evaluate whether or not the Cell’s value had, indeed, changed and fire the corresponding event appropriately I must admit, this works, but feels like more of a work around than a solution. Further, let’s say that you’d like to know as soon as the user has made a change to their selection.
You might want to handle this for a number of reasons: to enable a save button, to change the appearance of selected items, to display a pop-up window, or to check for consistency against other choices.However, pressing the Esc key in this situation will revert the initial value of the cell and it will close the editor. The Row Validating event has a slightly different behavior.When the validation fails, the editor is closed, but the user cannot change the current row in the grid until a valid cell value is entered.Also, the drop down list will add / remove handlers so you can easily test out which handlers do what without having to specifically comment out lines of code.provides a convenient way to realize data validation before it is committed to the underlying data source.SOLUTION To achieve data validation prior the row is committed, you can handle the Cell Validating event, which is raised by the control when the current cell changes or when it goes out of edit mode.