I have a grid for which I have defined 2 dataRowStyle’s, so that I can get alternating row colours. However, I’d also like to adjust the colour of a particular column in the grid as well to have different colours.
row0.BackColor = White
row1.BackColor = Grey
But in row0.column5 I want .BackColour = PaleYellow
and in row0.column6 I want .BackColour = DarkYellow
Is this setup possible? I can’t work it out in the grid designer. I thought about writing a handler for the Cell.Paint event to modify the cell colours, but I can’t work out how to determine the original dataRowStyle for a cell.
Solving either of those problems will help.
Imported from legacy forums. Posted by RJ (had 1355 views)
This can be done by deriving from the DataRow and DataCell classes, in which you can override the GetDisplayVisualStyle method, so to get the color you want on the cell according to the parent row color.
I have attached a sample application demonstrating this.
Imported from legacy forums. Posted by André (had 649 views)