Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu May 04, 2006 10:52 pm Post subject: How do I set different styles for individual cells? |
|
|
Typically you do this by handling the GetRowData and GetCellData events and setting the OddStyle and EvenStyle for the CellData. Note that you can't just set the color properties of the default styles - this will set the colors of all cells that use this style (which by default is every cell in the tree). If you want a cell to have a different back or fore color then you need to assign it a new (or different) Style. For example in GetCellData you could do:
Code: |
Style highlightStyle = new Style(cellData.OddStyle);
highlightStyle.BackColor = Color.Red;
cellData.EvenStyle = highlightStyle;
cellData.OddStyle = highlightStyle;
|
If you know upfront what colors/styles you need it would be better for performance to create the highlight style in your constructor and just do the assignments in GetRowData/GetCellData. _________________ Infralution Support |
|