DataGridView 设置某行的颜色
方式一
AddHandler Me.TableViewLotFamily.DataGridView.RowPrePaint, AddressOf dgvPrePainting
Private Sub dgvPrePainting(sender As Object, e As DataGridViewRowPrePaintEventArgs)
If _RowIndex >= 0 AndAlso e.RowIndex = _RowIndex Then
Dim br As SolidBrush = New SolidBrush(Color.LightBlue)
e.Graphics.FillRectangle(br, e.RowBounds)
'e.Graphics.DrawRectangle(Pens.Gray, e.RowBounds)
ElseIf e.RowIndex >= 0 Then
Dim br As SolidBrush = New SolidBrush(Color.White)
e.Graphics.FillRectangle(br, e.RowBounds)
'e.Graphics.DrawRectangle(Pens.Gray, e.RowBounds) 设置边框
End If
End Sub
方式二
CType(sender, DataGridView).Rows(e.RowIndex).Selected=True 改变颜色
If TableViewLotFamily.DataGridView.Rows.Count > 0 Then