Home Forums WinForms controls Xceed Grid for WinForms different cell colors in the selected row Reply To: different cell colors in the selected row

User (Old forums)
Post 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);
            graphics.DrawRectangle(Pens.Black, borderRectangle);

Imported from legacy forums. Posted by Buzz (had 1268 views)