-1

I would like to know how i can remove these rows insted of making them green

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    'test
    Dim examplea As String = "PAID"
    If DataGridView1.Rows.Count > 0 Then
        For i = 0 To DataGridView1.Rows.Count - 1
            If examplea = DataGridView1.Rows(i).Cells("PROJECT").Value.ToString Then
                ' MessageBox.Show("record already exist")
                DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.green
                'DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
            Else
                ''MsgBox("N-E")
                'Exit For
            End If
        Next
    End If
    'test
End Sub
LabRat
  • 1,996
  • 11
  • 56
  • 91

1 Answers1

0

Not sure I am entirely understanding what you need except you want to remove a row...

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    'test
    Dim examplea As String = "PAID"
    If DataGridView1.Rows.Count > 0 Then
       For i = DataGridView1.Rows.Count - 1 To 0 Step -1
            If examplea = DataGridView1.Rows(i).Cells("PROJECT").Value.ToString Then
                ' MessageBox.Show("record already exist")
                'DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.green
                DataGridView1.Rows.RemoveAt(i)
            Else
                ''MsgBox("N-E")
                'Exit For
            End If
        Next
    End If
    'test
End Sub
Trevor
  • 7,777
  • 6
  • 31
  • 50