像这样显示的表,里面有图片。用哪种控件比较好 ,怎么显示呢?
------解决方案--------------------------------------------------------
为了在DBGrid中显示图象,要设置OnDrawColumnCell事件。
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;
------解决方案--------------------------------------------------------
把图存进数据库:
http://hi.baidu.com/perock/item/d35d193886c18f5880f1a7ee
------解决方案--------------------------------------------------------
存的是路径的话,可以照着上面的思路,图片读取为内存流,然后在表格中加载。
MyImage := TMemoryStream.Create; //建立内存流对象
Get(picUrl, MyImage);
localUrl := ExtractFilePath(ParamStr(0)) + '\Pic.jpg';
MyImage.SaveToFile(localUrl);
Image1.Picture.LoadFromFile(localUrl);
大致思路如此