I have a DataGridView with four columns. The first three are returned back as an array: red, green and blue. All values are between 0 and 255. I've programmatically added a column called "Colour". I'd like the backcolor of this column to reflect the RGB content. I can see the rgb data correctly, and using the debugger, the backcolor is being set correctly against the property. I can also set the column's backcolor and it displays correctly. I've tried setting the "Red" cell's backcolor and this doesn't work either.
The below code results in a completely white column.
Here's my code:
DataGridViewColumn DGC = new DataGridViewColumn();
DGC.Name = "Colour";
DGC.CellTemplate = new DataGridViewTextBoxCell();
dgPallette.Columns.Add(DGC);
foreach (DataGridViewRow DGR in dgPallette.Rows)
{
Color cellColor = Color.FromArgb(
int.Parse(DGR.Cells["Red"].Value.ToString()),
int.Parse(DGR.Cells["Green"].Value.ToString()),
int.Parse(DGR.Cells["Blue"].Value.ToString()));
DGR.Cells["Colour"].Style.BackColor = cellColor;
}
Any ideas?
Thanks in advance Jim