private
{ Private declarations }
public
f:Integer;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
bRect:TRect;
State:TGridDrawState;
begin
f:=1;
bRect:=DrawGrid1.CellRect(0,0);
DrawGrid1DrawCell(TObject(DrawGrid1),0,0,bRect,State);
end;
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Bmp: TBitmap;
Str1:string;
i:Integer;
re:TRect;
begin
if f=1 then
begin
ACol:=0;
ARow:=0;
Str1:='123456789';
for i:=1 to Length(Str1) do
begin
//if (ACol=j) and (ARow=k) then
begin
DrawGrid1.Update;
re:=DrawGrid1.CellRect(arow,acol);
//ShowMessage(IntToStr(acol)+' '+IntToStr(arow));
Bmp:=TBitmap.Create;
Bmp.LoadFromFile('D:/test/新建文件夹/imgs/a'+copy(Str1,i,1)+'.bmp');
DrawGrid1.Canvas.StretchDraw(re,bmp);
Bmp.Free;
if acol>=4 then
begin
Inc(ARow);
ACol:=0;
end
else
begin
Inc(ACol);
end;
end;
end;
end;
// case ACol of
// 0:
// begin
// Bmp := TBitmap.Create;
// Bmp.LoadFromFile('D:/test/新建文件夹/imgs/ma_03.bmp');
// DrawGrid1.Canvas.StretchDraw(Rect, Bmp);
// Bmp.Free;
// end;
// 1:
// begin
// Bmp := TBitmap.Create;
// Bmp.LoadFromFile('D:/test/新建文件夹/imgs/ma_05.bmp');
// DrawGrid1.Canvas.StretchDraw(Rect, Bmp);
// Bmp.Free;
// end;
// end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
f:=0;
end;