1,105,363 Community Members

Datagrid column1 value depends on column2 value

Member Avatar
gbhs
Light Poster
40 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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
Member Avatar
xerohomicide
Newbie Poster
24 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

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
Member Avatar
gbhs
Light Poster
40 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Question Answered as of 1 Year Ago by xerohomicide
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article