怎样让dbgrid里面插入图像,多谢
解决方案 »
- fastreport如何合并相同的行?
- 请教关于ClientDataSet的排序问题
- 请问如何把JPG图片存入数据库 在线//
- 如何做程序让多台电脑对其中一台电脑上的数据库进行访问与维护?
- 模仿Delphi设计界面。。。高手请进。。。在线等待。。。30分。。
- 感谢党的三农政策,俺家第一次从政府领到钱
- 怎么让我任务栏不增加图标
- 我的程序怎么老是出现kerner32.dll出错,请高手指点!!!
- 请问如何在dpr文件中声明一个公共变量(全局变量)?应该在哪个位置声明?
- 如何在mdiform上放文字?不能挡住子窗口
- 请高手进来看看
- 各位高手,能不能调用WINDOWS的“画图”呀,就是开始菜单附件那个,马上给分
Field: TField; State: TGridDrawState);
begin
dbgrid1.Canvas.Draw(Rect.Left,Rect.Top,application.Icon);
end;
DBGrids, DB, DBTables, Grids, WinTypes, Classes, Graphics;type
TDBPicGrid = class(TDBGrid)
protected
procedure DrawDataCell(const Rect: TRect;
Field: TField; State: TGridDrawState); override;
public
constructor Create(AOwner : TComponent); override;
published
property DefaultDrawing default False;
end;procedure Register;implementationconstructor TDBPicGrid.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
DefaultDrawing := False;
end;procedure TDBPicGrid.DrawDataCell(const Rect: TRect; Field: TField;
State: TGridDrawState);
var
bmp : TBitmap;
begin
with Canvas do
begin
FillRect(Rect);
if Field is TGraphicField then
try
bmp := TBitmap.Create;
bmp.Assign(Field);
Draw(Rect.Left, Rect.Top, bmp);
finally
bmp.Free;
end
else
TextOut(Rect.Left, Rect.Top, Field.Text);
end;
end;procedure Register;
begin
RegisterComponents('Custom', [TDBPicGrid]);
end;end.
Field: TField; State: TGridDrawState);
var
bmp : TBitmap;
begin
with DBGrid1.Canvas do
begin
FillRect(Rect);
if Field is TGraphicField then
try
bmp := TBitmap.Create;
bmp.Assign(Field);
Draw(Rect.Left, Rect.Top, bmp);
finally
bmp.Free;
end;
end;
end;