我把一些图片保存在数据库的一个字段中,如何才能把数据库字段中的图片在运行期添加到TImageList控件中,以便提供给ListView的Item使用!

解决方案 »

  1.   


    procedure LoadIcon(IconPath:string;var ImageList:TImageList);
    var
      sr: TSearchRec;
      FileAttrs: Integer;
      Path:string;
      i : integer;
      BitMap1 : TBitMap;
    begin
      i := 0;
      ImageList.Clear;
      path:=IconPath+'*.bmp';
      if FindFirst(path, 0, sr) = 0 then
      begin
        BitMap1 := TBitMap.Create;
        i := i+1;
        BitMap1.LoadFromFile(IconPath+IntToStr(i)+'.bmp');
        ImageList.Add(BitMap1,nil);
        while FindNext(sr) = 0 do
        begin
          i := i+1;
          try
            BitMap1.LoadFromFile(IconPath+IntToStr(i)+'.bmp');
            ImageList.Add(BitMap1,nil);
          except
            continue;
          end;
        end;
      end;
    end;