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;
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With