我想知道如何删除这些让它们变绿的行
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
答案 0 :(得分:0)
我不确定我完全理解你需要什么,除非你想删除一行...
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