The Data Bound Item will be updated only if the cell is validated.However, the user may prefer to validate all the data cells in a row at once. Value) str Result = Date Diff("D", Hire Date, Due Date) If str Result Rory (Clissold Solutions) The cell Validating event fires before the Data Grid View gets updated, so you can't get the new value from the Data Grid View object. (If you debug your current code you'll find that Due Date gets populated with the old value of the cell, not the new value. Formatted Value will hold the new value) - Rory Private Sub Rental Data Grid View_Cell Validating(By Val sender As Object, _ By Val e As System. Cell Validating Try With Rental Data Grid View If e. Formatted Value "" Then Dim Due Date As Date Dim Hire Date As Date Dim str Result As Integer Due Date = CDate(e. Steps to recreate are as follows:- Create a form, form1, and set its MDIContainer property to true Create another form, form2, and add a button to form1 that creates an instance of form2 and sets its MDIParent property to form1 Create a Data Set and add a Data Table to it Add a single column to the Data Table and set its Allow DBNull property to false Add a Data Grid View to form2 and link it to the Data Table via a Binding Source component and an instance of the Data Table dragged from the Toolbox Add a button or some other control that you can click to take focus away from the grid Finally add a Row Validating handler to the Data Grid View and add the following code Run the application Click in the cell and press a key so that the row goes into edit mode Now press backspace to delete whatever you typed so the cell is empty (DBNull) Try to click in the textbox......CPU jumps to 100 % and you have to kill the application from Task Manager If you stop form2 from being an MDI child the problem stops occuring and the validation works as expected.I have seen a couple of similar posts in my search for an answer, but no solution.It seems to be so easy to recreate I think there must be a known issue with this somewhere Anyone have any ideas TIA Ken Tucker I usually assign a value to a cell that does not allow nulls in the Data Grid View's Default Values Needed event.
It never actually reaches the code behind the button, and I have found that if I simply put e.
So I have added an event handler to the Data Grid View.
Row Validating event to try and deal with this and I check the relevant columns all have a value within this event.
"but when i correct and enter a valid date, i still get an error. Data Grid View Cell Validating Event Args) _ Handles Rental Data Grid View.
Private Sub Rental Data Grid View_Cell Validating(By Val sender As Object, _ By Val e As System. Cell Validating Try With Rental Data Grid View If e.
I am able to hide the error through the Data Error event, but this does not prevent the original problem of new rows being removed if you leave the row and hit an error. Cancel option, and if I set it to true I get the same infinite loop problem.