Для меня CellFormatting
делает трюк. У меня есть набор столбцов, которые можно редактировать (которые я сделал, чтобы они отображались другим цветом), и это код, который я использовал:
Private Sub Util_CellFormatting(ByVal Sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgvUtil.CellFormatting
If dgvUtil.CurrentCell IsNot Nothing Then
If e.RowIndex = dgvUtil.CurrentCell.RowIndex And e.ColumnIndex = dgvUtil.CurrentCell.ColumnIndex And (dgvUtil.CurrentCell.ColumnIndex = 10 Or dgvUtil.CurrentCell.ColumnIndex = 11 Or dgvUtil.CurrentCell.ColumnIndex = 13) Then
e.CellStyle.SelectionBackColor = Color.SteelBlue
Else
e.CellStyle.SelectionBackColor = dgvUtil.DefaultCellStyle.SelectionBackColor
End If
End If
End Sub