vb.net 根据内容设置DataGridView行背景色

''设置特殊行背景色

Private Sub DataGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting

If Me.DataGridView1.Columns(e.ColumnIndex).Name = "备注" Then

If e.Value IsNot Nothing Then

If e.Value = "黑名单" Then

Me.DataGridView1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.YellowGreen

End If

End If

End If

End Sub