TrzDbGrid

Viewing 1 reply thread
  • Author
    Posts
    • #405
      Corrado Piccini
      Participant

        Good morning.
        I use TrzDbGrid (ver 6.2.2) with Delphi 10.0.
        I defined an event (OnDrawColumnCell) but the event is never called. I followed with debug, I see that OnDrawColumnCell runs in vcl.dbgrids but never the one defined in my program. Some idea?

      • #407
        Ray Konopka
        Keymaster

          Hi,

          In order for the OnDrawColumnCell event to fire, you need to set the DefaultDrawing property to False. Then you need to handle drawing the content of all the cells. Here is a simple example:

          procedure TForm29.RzDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
            State: TGridDrawState);
          begin
            if Column.FieldName = 'AB' then
              RzDBGrid1.Canvas.Brush.Color := clRed
            else
              RzDBGrid1.Canvas.Brush.Color := clYellow;
            RzDBGrid1.DefaultDrawColumnCell( Rect, DataCol, Column, State );
          end;

          The code above results in every cell of the grid having a background of Yellow, except for the ‘AB’ column which has a background color of Red. The DefaultDrawColumnCell method is used to actually to the drawing.

          Ray

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.