Results 1 to 5 of 5

Thread: {Resolved} VB.NET 2005 - DataGridView - CellValidating

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    369

    Resolved {Resolved} VB.NET 2005 - DataGridView - CellValidating

    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
    Last edited by dbelley_office; Aug 8th, 2007 at 09:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width