User (Old forums)MemberOctober 5, 2009 at 1:46 pmPost count: 23064
We are currently setting the background color of particular cells in the Xceed grid depending on the data values in the cell. So, for example, if a certain flag is set for the row, we color the Total Price cell’s background red. The problem is that when we select a row with a cell that has a special color, the selected row color overwrites that cell’s color. If we choose a different row to select, the cell is colored correctly again now that it is unselected. Is there any way to get the special color to “show through” the selected row background color?
Imported from legacy forums. Posted by Rachel (had 1724 views)Diane [Xceed]ModeratorOctober 22, 2009 at 3:45 pmPost count: 1353
This behavior is normal, and is caused by the order in which the different layers are painted. The selection color is painted after the cell’s background, and will therefore ‘override’ it.
There’s two options that we can suggest. You can either make your selection color be transparent, so that if a cell has a background color it will be able to show through. Note however that the color will ‘merge’ with the selection color (if the cell’s background is red and your selection color is a light blue, the cell will appear as a red leaning slightly on purple).
The other option is to remove completely the selection color and instead use only the focus rectangle as your indicator of which row is currently selected.
Imported from legacy forums. Posted by Diane [Xceed] (had 404 views)User (Old forums)MemberOctober 22, 2009 at 3:57 pmPost count: 23064
You can set the grid.SelectionBackColor to a color you want, with an alpha value to make it opaque.
I too am setting certain cell background colors. The opaque selection allows most of the background color to come through.
I’m using a stylesheet I got from the Validation sample, and modified it to this:
styleSheet.Grid.SelectionBackColor = Color.FromArgb(40, Color.Cyan);
styleSheet.Grid.SelectionForeColor = Color.FromArgb(29, 50, 139);
I also subclassed the GridControl and overrided PaintFocusRectangle, to draw a more prominent border around a selected cell. I’m not sure I like the look yet, but it’s a start. Hope this helps.
protected override void PaintFocusRectangle(VisualGridElement gridElement, Graphics graphics, Rectangle displayRectangle, Color backColor, Color foreColor, bool printing)
// Draw a black border around the cell.
Rectangle borderRectangle = new Rectangle(displayRectangle.X, displayRectangle.Y, displayRectangle.Width – 1, displayRectangle.Height – 1);
Imported from legacy forums. Posted by Buzz (had 1268 views)
- You must be logged in to reply to this topic.