procedure TForm1.Button1Click(Sender: TObject); var Item:Tlistitem; //LISTVIEW1的行 begin AdoQuery.close; AdoQuery.SQL.Clear; AdoQuery.SQL.Add('select * from pic2db where vid=2'); AdoQuery.open; while not AdoQuery.Eof do begin Item:=ListView1.Items.Add; Item.Caption:=AdoQuery.Fields[2].asstring; IconStream:=TMemoryStream.Create; (AdoQuery.FieldByName('icon') as TBlobField).savetostream(IconStream); IconStream.Position:=0; Icon :=TIcon.Create; Icon.LoadFromStream(IconStream); ImageList1.AddIcon(Icon); ListView1.ViewStyle:=vsIcon; ListView1.LargeImages:=ImageList1; Item.ImageIndex := ImageList1.Count-1; AdoQuery.Next; messagebox end; end; ========================== 关键是下面这句: (AdoQuery.FieldByName('icon') as TBlobField).savetostream(IconStream); 你也可以存成一个文件,savetofile
var
Item:Tlistitem; //LISTVIEW1的行
begin
AdoQuery.close;
AdoQuery.SQL.Clear;
AdoQuery.SQL.Add('select * from pic2db where vid=2');
AdoQuery.open;
while not AdoQuery.Eof do
begin
Item:=ListView1.Items.Add;
Item.Caption:=AdoQuery.Fields[2].asstring;
IconStream:=TMemoryStream.Create;
(AdoQuery.FieldByName('icon') as TBlobField).savetostream(IconStream);
IconStream.Position:=0;
Icon :=TIcon.Create;
Icon.LoadFromStream(IconStream);
ImageList1.AddIcon(Icon);
ListView1.ViewStyle:=vsIcon;
ListView1.LargeImages:=ImageList1;
Item.ImageIndex := ImageList1.Count-1;
AdoQuery.Next;
messagebox
end;
end;
==========================
关键是下面这句:
(AdoQuery.FieldByName('icon') as TBlobField).savetostream(IconStream);
你也可以存成一个文件,savetofile