1,978
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bmp:tbitmap;
outrect:trect;
bmpwidth:integer;
begin
outrect:=rect;
if (column.Field =table1.fields.FieldByName('Common_Name')) then
begin
bmp:=tbitmap.Create;
try
bmp.Assign(table1.fieldbyname('Graphic'));
bmpwidth:=(rect.Bottom -rect.Top )*2;
outrect.Right :=rect.Left +bmpwidth;
dbgrid1.Canvas.StretchDraw(outrect,bmp);
except
bmp.free;
end;
if table1.fieldbyname('Length (cm)').asinteger>100 then
begin
dbgrid1.Canvas.Font.color:=clred;
dbgrid1.Canvas.Font.style :=[fsbold];
end;
outrect:=rect;
outrect.left:=outrect.Left +bmpwidth;
end;
//dbgrid1.defaultdrawdatacell(rect,column.field,state);
dbgrid1.DefaultDrawDataCell(outrect,column.field,state);
end;