Hi,
I am trying to style grid columns with CellActivation=AllowEdit. When I select GridCell in AppStylist, it gives me an option for EditMode and ReadOnly, but I could not find a way to color the cells that are editable (i.e. for all cells, not just in edit mode). Is there a way to do this?
Thanks.
Editable is the default. So you would just style the Normal state. If you want to distinguish editable cells from ReadOnly cells, then you could style the ReadOnly state.
Yes, of course! I have another problem though. When I set the default row color and alternate row color, then set the read-only cells to different color, alternate row color only appears in editable cells, not all of them.
Thank you.
In general, the way it works is that the more specific appearance override the less specific one. Sometimes, less specific and more specific are arbitrary. In this case, the ReadOnly state overrides the AlternateRow state. So there's no away around that.
One way to handle this would be to use a gradient or a hatch style for your ReadOnly cells. You could specify only the BackColor2 and a gradient or hatch style and the BackColor2 would be merged with the existing color.
Another option would be to color the read-only cells in the grid yourself using the Appearance property on the cell. You would typically do this inside the InitializeRow event. If you still want the colors to be modifiable via AppStylist, you would use a resource in your isl file and assign that Resource to the cell using the cell.Appearance.StyleResourceName. You would, of course, need 2 resources - one for read-only cells in a normal row and one in the alternate row.