Oops (typo):
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
n: Integer;
begin
n := StrToIntDef(StringGrid1.Cells[ACol,ARow],-1);
if n >= 0 then
ImageList1.Draw(StringGrid1.Canvas,Rect.Left,Rect.Top,n)...