Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display imagelist items in Timage

Tags:

delphi

i have create 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;
like image 665
user367856 Avatar asked Aug 02 '10 04:08

user367856


1 Answers

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);
like image 92
Uwe Raabe Avatar answered Oct 17 '22 08:10

Uwe Raabe