开发者

display imagelist items in Timage

i have crea开发者_C百科te an imagelist with 20 bitmap inside and a dropdownlist value from 1 to 20. when i select the dropdownlist, it should show the bitmap that corresponding to the dropdownlist index. I'm facing problem that it keep showing the same image when i select the dropdownlist and the image too small. Any idea to slove this problem? and make the image larger?

procedure TForm1.FormShow(Sender: TObject);
var
  i : integer;
begin
  for i:=0 to 20 do begin
    cboIcon.Items.Add(inttostr(i));
  end;
end;

procedure TForm1.cboIconChange(Sender: TObject);
begin
  ImageList1.Draw (Image1.Canvas, 0,0, cboIcon.ItemIndex);
end;


You can try this code:

Image1.Stretch := true;  // to make it as large as Image1
Image1.Proportional := true;  // to keep width/height ratio
Image1.Picture.Bitmap:= nil; // clear previous image
ImageList1.GetBitmap(cboIcon.ItemIndex, Image1.Picture.Bitmap);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜