Everytime I validate a cell in my datagridview, it enters in the event multi times. So If there is an error I see the messagebox many times and if the value is correct, it still makes the validation twice.
EDIT:
One thing I just noticed. If on a line a provoque an error, I get the error message twice. If I change line and provoque an error, I get the error message 3 times and it continues on an on 4-5-6-7-8 times ... so it always increases by one. Anyone can explain that ?
Here is my code:
Code:'This line is in the function where I fill the grid. AddHandler grdInfo.CellValidating, AddressOf ValidateGridEntry Private Sub ValidateGridEntry(ByVal sender As Object, ByVal e As Windows.Forms.DataGridViewCellValidatingEventArgs) Dim lngRet As Long = 0 If e.RowIndex < 0 OrElse e.FormattedValue.ToString = String.Empty Then Exit Sub If e.ColumnIndex = grdInfo.Columns("regCode").Index Then lngRet = ValiderReglement(e.FormattedValue.ToString.Trim) If lngRet = 0 Then ShowMessage(My.Resources.MSG_WARNING_CODE_REGLEMENT_INEXISTANT, mERROR) e.Cancel = True Else If grdInfo.CommitEdit(DataGridViewDataErrorContexts.Commit) = False Then ShowMessage(My.Resources.MSG_WARNING_PROBLEME_COMMIT_CELLULE, mERROR) End If End If End If End Sub




Reply With Quote