TimageList does not contain a member named GetBitmap

Viewed 2921

I want to load pictures from an ImageList to a TImage (mobile application, fmx). The TImage is part of my customstyle Listbox (LBItem.StylesData['myimage']). The standard approach would be ImageList.GetBitmap(). However the GetBitmap method gives me an error: 'TimageList does not contain a member named GetBitmap'. Any explanation or alternatives? Thanks in advance!

procedure TForm3.Button1Click(Sender: TObject);
var
    i         : Integer;
    LBItem    : TListBoxItem;
    Bitmap : TBitMap;
begin
    ListBox1.BeginUpdate;
    ListBox1.Items.Clear;
    Bitmap := TBitMap.Create;
    try
        for i := 0 to 3 do begin
            LBItem := TListBoxItem.Create(nil);
            LBItem.Parent := ListBox1;
            LBItem.StyleLookup := 'mystyle';
            LBItem.StylesData['mylabel'] := 'Some text...';
            //Bitmap.LoadFromFile('D:\Koala.jpg');
            ImageList1.GetBitmap(i, Bitmap);
            LBItem.StylesData['myimage']:= Bitmap;
        end;
    finally
        ListBox1.EndUpdate;
    end;
end;
3 Answers

In FMX you don't need any additional coding for that, just use TGlyph instead of TImage if you want to display images directly form ImageList.

example :

Glyph1.ImageIndex := i;
Related