unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, ImgList;

type
  TForm1 = class(TForm)
    DrawGrid1: TDrawGrid;
    DrawGrid2: TDrawGrid;
    ImageList1: TImageList;
    procedure DrawGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{$J+}
 //wypelnienie komorek tabeli Drawgrid1 roznymi obrazami z listy //TImageList
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
const
  index: integer=0;
begin
    //komórki wypełniane wierszami po kolei poza 0 wierszem
  //i 0 kolumną
  if (ARow<>0) and (ACol<>0) then
  begin
    index := ARow * (Drawgrid1.Colcount-1) + ACol-Drawgrid1.ColCount;
    ImageList1.Draw(Drawgrid1.Canvas,Rect.Left,Rect.Top,index);
    inc(index);
  end;

end;

 //wypelnienie komorek tabeli Drawgrid2 roznymi obrazami z listy TImageList
procedure TForm1.DrawGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
const
   index1: integer=0;
begin
  //komórki wypełniane wierszami po kolei
    index1 := ARow * Drawgrid2.Colcount + ACol;
    ImageList1.Draw(Drawgrid2.Canvas,Rect.Left,Rect.Top,index1);
    inc(index1);

end;


end.
