is possible invoke in runtime the TImagelist editor to see the contents of my TImagelist
?
2
votes
3 Answers
6
votes
That editor is a design-time editor and is not available at runtime, but you can draw any of the images saved inside an ImageList on any canvas by calling its Draw method and specifying index of the image which you want to draw. The sample code below draws all images saved inside ImageList1 on Form1 in a vertical list:
var
i : Integer;
begin
for i := 0 to ImageList1.Count-1 do
ImageList1.Draw(Form1.Canvas, 16, 16 + (i * ImageList1.Height),i,True);
end;
5
votes
You can drop a ListView on some form and do something like this:
var
i: Integer;
li: TListItem;
begin
ListView1.LargeImages := ImageList1;
ListView1.Items.BeginUpdate;
try
for i := 0 to Pred(ImageList1.Count) do
begin
li := ListView1.Items.Add;
li.Caption := Format('Image %d', [i]);
li.ImageIndex := i;
end;
finally
ListView1.Items.EndUpdate;
end;
end;