title: Delphi DBGrid alternate row colors for all DBGrids in the project
body: <p>How can I make all my grids look the same way all over my forms?
  I want to implement an alternate row color that must be applied on all grids of my project. Is it possible without adding the same DrawColumnCell event code for every grid?
  I want to avoid adding the same code for each of my grids. I have like 30 grids in my project and multiplied by 13 rows of code it just adds a lot of code lines to my project making it "unfriendly".
  I am looking for a solution that will only add 13 lines of code to the project, not 390 lines.</p>
  
  <p>My formatting code looks like this (for example):</p>
  
  <pre><code>procedure TDBGrid.DBGrid1DrawColumnCell(Sender: TObject;const Rect: TRect;DataCol: Integer;Column: TColumn;State: TGridDrawState) ;
  var
     grid : TDBGrid;
     row : integer;
  begin
     grid := sender as TDBGrid;
     row := grid.DataSource.DataSet.RecNo;
     if Odd(row) then
       grid.Canvas.Brush.Color := clSilver
     else
       grid.Canvas.Brush.Color := clDkGray;
     grid.DefaultDrawColumnCell(Rect, DataCol, Column, State) ;
  end;
  </code></pre>
  
  <p>Probably I would need to extend the DBGrid somehow, but I do not know exactly how nor how to look for a solution for this on google</p>
  
  <p>I tried to hack the DBGRid inside each form like this:</p>
  
  <pre><code>type
    TDBGrid = class(DBGrids.TDBGrid)
    protected
      procedure DrawColumnCell(const Rect: TRect; DataCol: Integer;Column: TColumn; State: TGridDrawState); override;
    end;
  ...
  procedure TDBGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer;Column: TColumn; State: TGridDrawState) ;
  var
         grid : TDBGrid;
         row : integer;
  begin
         row := 2;//grid.DataSource.DataSet.RecNo;
         if Odd(row) then
           Canvas.Brush.Color := clSilver
         else
           Canvas.Brush.Color := clDkGray;
         DefaultDrawColumnCell(Rect, DataCol, Column, State) ;
  end;
  </code></pre>
  
  <p>I can do this but I cannot access the sender, so I can access the dataset and know which record to color and which not (odd and even).
  And this is a poor approach anyways since I will have to do it on every form, so it's not really a solution</p>
  
  <p>Any ideas?</p>
  
  <p>Thank you</p>