Hi Linda,
I am a little bit confused. I thought setting the cancel to true would negate the change in the cell and return focus to the cell. The value of cancelis false when the CellValidate code starts, right? Regardless, except for one column I don't set the cancel to anything in the cellvalidating event. For that one column, I set it to true if the value is not what it should be.
The action in theprogram is this: I have a "Save" button on the form that does a SQL transaction.Commit. After being in the datagridview, when the user clicks that button, the various events for the grid fire but the code for the click event for the button does not fire. The button has focus but the click event does not fire. It did before but it stopped working after I added a bunch more code in the CellValueChanged section That additional code in the CellValueChanged section calculates some values for some unbound columns.
I consulted a VB2005 guru from the Tulsa .Net Users Group and he suggested adding some code for the MouseHover event on the save button. That code is below. Now when the user moves the mouse pointer over the save button, the various events for the DGV fire. And the code under the click event for the Save button fires when the user clicks it.
What do you think? Is there a reason the click event for the Save button will not fire after moving the mouse from the grid to the button and clicking on it? That is, it will not fire unless I have the MouseHover code as below.
Private Sub btnSave_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnSave.MouseHover
btnSave.Focus()
End Sub