Alternate Row Shading problem

Viewing 2 reply threads
  • Author
    Posts
    • #2341
      Barry Wood
      Participant

        Hi,

        With AltRowShading un-checked on a dbgrid the selected row colour is a light blue on all rows, making the underlying text easy to read. However, with AltRowShading checked the selected row colour alternates between light blue (on unshaded rows) to dark blue (on shaded rows). The dark blue makes the text very hard to read clearly (see below).

        I can’t see any setting for this selected row colour, either in the dbgrid properties or the Frame Controller properties.

        Without AltRowShading checked

        Is there a setting somewhere to change this?

      • #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

        • #2601
          Barry Wood
          Participant

            Ray,

            HaHa, wondered if you had missed it, but thought you were ay too busy doing other stuff to get round to it. Many thanks.

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.