Hi Folks
As a newbie, my datagrid (dgvExamScores)has column4 and column5 (and othercolumns)
column4 values depend on column5 values. Code works fine.
PROBLEM:
when I delete a column5 value, I expect the corresponding column4 to be deleted but this is not the case.
Just where have I erred in my code below.
Is this the correct event to use?

Private Sub dgvExamScores_CellValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvExamScores.CellValidated
        For i As Int32 = 0 To Me.dgvExamScores.Rows.Count - 1
            If Not IsDBNull(Me.dgvExamScores.Rows(i).Cells(5).Value) Then
                Me.dgvExamScores.Rows(i).Cells(4).Value = Me.txtCreditValue.Text
            Else
                IsDBNull(Me.dgvExamScores.Rows(i).Cells(4).Value)
            End If

        Next

    End Sub

try..

Private Sub dgvExamScores_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvExamScores.CellValueChanged
            For i As Int32 = 0 To Me.dgvExamScores.Rows.Count - 1
                If Me.dgvExamScores.Rows(i).Cells(5).Value <> Nothing Then
                    Me.dgvExamScores.Rows(i).Cells(4).Value = Me.txtCreditValue.Text
                Else
                   ' IsDBNull(Me.dgvExamScores.Rows(i).Cells(4).Value)
                End If
            Next
    End Sub

Thank very much.
I was missing the event to use.
For loop seems to take more processing time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.