View previous topic :: View next topic |
Author |
Message |
Stuart Guest
|
Posted: Mon Mar 27, 2006 8:07 pm Post subject: Row Color |
|
|
Hi,
I've seen a few threads on setting individual rows to a different colour, and it works but I also need to preserve the current alignment settings, how would I go about this?
At the moment when I handle GetCellData and set the odd+even styles to the style I've created with a different BackColor, it also overrides the alignment I've set for each column and everything is left aligned. Is there an easy way to fix it?
Thanks,
Stuart |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Mar 27, 2006 9:25 pm Post subject: |
|
|
Try the following code in your GetCellData method:
Code: |
if (highlighted)
{
cellData.EvenStyle = new Style(cellData.EvenStyle);
cellData.EvenStyle.Backcolor = Color.Red;
cellData.OddStyle = cellData.EvenStyle;
}
|
This assumes that you want odd and even rows to be the same when highlighted. Because the new style you create inherits from the current cell style and only overrides the backcolor it will preserve the alignment. _________________ Infralution Support |
|
Back to top |
|
|
|