Reputation: 14507
How to find the DataGridViewCell background color in C# - windows application?
Upvotes: 0
Views: 750
Reputation: 284
If you need this information in order to alter the rendering of the cell, you could plug to the Paint or the Formatting event, which EventArgs has a CellStyle property with the background color inside.
Upvotes: 0
Reputation: 107536
Saw this on bytes.com, and another user claims it works, though I have not tested it (this is VB):
DataGridView1.Item(ColumnIndex, RowIndex).Style.BackColor = Color
or
DataGridView1.CurrentCell.Style.BackColor = Color
Also see the MSDN documentation:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.style.aspx
Upvotes: 2