procedure TMainFrm.GridFriendDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var
Picture:TPicture;
begin
TDBGrid (Sender).DefaultDrawColumnCell(Rect,3,Column,State);
if (Column.FieldName = 'F_PIC') then
try
Picture:=TPicture.Create;
Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'1.bmp');
TTntDbGrid(Sender).Canvas.StretchDraw(Rect,Picture.Graphic );
finally
Picture.Free;
end;
end;
State: TGridDrawState);
var
Picture:TPicture;
begin
TDBGrid (Sender).DefaultDrawColumnCell(Rect,3,Column,State);
if (Column.FieldName = 'F_PIC') then
try
Picture:=TPicture.Create;
Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'1.bmp');
TTntDbGrid(Sender).Canvas.StretchDraw(Rect,Picture.Graphic );
finally
Picture.Free;
end;
end;
本文介绍了一种在Delphi中使用DBGrid显示数据库图片的方法。具体实现为:当DBGrid的列字段名为'F_PIC'时,通过加载本地图片并利用TDBGrid的DefaultDrawColumnCell方法和Canvas的StretchDraw方法将图片绘制到指定单元格中。
720

被折叠的 条评论
为什么被折叠?



