Reply To: Alternate Row Shading problem

#2596
Ray Konopka
Keymaster

    Hi Barry,

    First of all, I want to apologize for what happened to this post and your other one on the same topic. I’m still not entirely sure how it happened, but your two posts were flagged by the forum software that our site uses and required approval before being published. Unfortunately, I missed the notification and noticed them when I was doing some site maintenance.

    As for the behavior that you are reporting, that is actually coming from the lower-level TCustomGrid code and the default setting for DrawingStyle of gdsThemed. The low-level code is blending the highlight color with the color of the cell, which is resulting in the darker blue color for the shaded cells.

    To work around this, you can try using a different setting for DrawingStyle, or write an event handler for the OnDrawColumnCell event. For example,

    procedure TForm16.RzDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    begin
      if gdSelected in State then
      begin
        RzDBGrid1.Canvas.Brush.Color := clRed;
        RzDBGrid1.Canvas.Font.Color := clWhite;
      end;
      RzDBGrid1.DefaultDrawColumnCell( Rect, DataCol, Column, State );
    end;

    The above code will result in the selected row always being displayed as white text on a red background.

    Ray