I am setting cellappearance.backcolor of cells at design time, essentially highlighting a column in the grid. But I am setting row.appearance.backcolor in InitializeRows which I would like to replace the cell back color, but its not.
Is there a switch or something that I can flip to cause the row appearance to take precidence over the cell appearance?
Thanks
M
Hi M,
The way appearance resolution works is that the more specific appearance always takes precedence over the less specific one. In this case, a cell is more specific than a row, so the cell appearance takes precedence.
This is very powerful in that it allows you to set appearances on a large scale and override it on a small scale. You can set the BackColor of every cell in the grid by setting a single property and then set the BakColor of the cells in a spefic band with another property. Then you can change a single row with one property, and a single cell, etc. It avoids the need for looping through large lists of objects to assign colors to big areas while still giving you fine control over each object.
If you want the row color to apply to a cell, then the thing to do is... don't set the color on the cell. Why would you set a color on the cell if you don't want to see it, anyway?
Thanks for the response.
That does make sense for sure, but I want to set the color at a column level and have the row level override that. But there isnt a "column" level to set it at, which leaves me at the "cell" leve which is lower than a "row" and doesnt work.
Any thoughts on how I can make a column all one color except when it is overwritten by a row color change?
Thanks again
Ah yes, I see what you are getting at.
That works perfect, that was exactly what I wanted.
Thanks for you help
No, you do not have to loop through the cells. I was not suggesting that you use the appearance on each Cell. I suggested that you use the row.CellAppearance. This appearance applies to every cell in the row and this appearance takes precedence over the column.CellAppearance.
The row has an Appearance property which applies to the row itself. It also has a CellAppearnce which applies to every cell in that row. It's a subtle, but important, distinction.
Did you try it?
Which is great for settting the backcolor of a "cell" but not a "row" I have 50+ columns that maybe visible or invisible based on user settings. I guess I could iterate through them setting them one at a time at every refresh to set the cell back color. Isnt there anything a little simpler? Seems like excessive processing, unless that is how it is done internally anyway.
The same way you do it with the Appearance on the Row or the CellAppearance on the ColumnHeader.
row.CellAppearance.BackColor = color
How do I use CellAppearance to alter the entire rows backcolor?