unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    DrawGrid2: TDrawGrid;
    ImageList2: TImageList;
    Label1: TLabel;
   procedure DrawGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);

  private
    { Private declarations }
  public
    { Public declarations }
  end;
  tekst=record
           wsp:TPoint;
           napis:shortstring;
          end;
var
  Form1: TForm1;
  w:string;
  ind:integer;
  tab_txt: array[0..20]of tekst;

implementation

{$R *.dfm}
{$J+}

//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;
     lista:array[0..7]of string=('Ala','Ola','Jola','Adam','Piotr','Paweł','Anna','Michał');
begin
index1 := ARow * Drawgrid2.Colcount + ACol;
  //komórki wypełniane wierszami po kolei
  case index1 of //ARow of
  0..3:   Drawgrid2.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,lista[index1]);
  4..7:   ImageList2.Draw(Drawgrid2.Canvas,Rect.Left,Rect.Top,index1-4);
  8..11:  Drawgrid2.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,lista[index1-4]);
  12..15: ImageList2.Draw(Drawgrid2.Canvas,Rect.Left,Rect.Top,index1-8);
  end;
    label1.Caption:=Label1.Caption+#13+Inttostr(index1);
 end;


end.
