troubleshooting Question

Populate an ImageList at runtime in Delphi (2010)

Avatar of Member_2_99151
Member_2_99151 asked on
Delphi
7 Comments1 Solution2224 ViewsLast Modified:
Hi all,

I have an app written in Delphi and I wish to do the following:

1. Add images dynamically to an ImageList
2. Display the contents of this list in a combo box.

This list may change as the program executes, so this needs to be dynamic.

At the moment I am using a "TPictureComboBox" by DarkAges to display the images and a standard ImageList to store the images.

I have tried the following to no avail....
    // Clean up existing
    while myImageList.Count > 0 do
    begin
        myImageList.GetBitmap(0, xBitmap);
        xBitmap.Free;
        myImageList.Delete(0);
    end;
    myImageList.Clear;

    // Now add them
    for I := 0 to myObjectWithBitmapArray.Count - 1 do
    begin
        xBitmap := TBitmap.Create;
        xBitmap.Assign(TObjectWithBitmap(myObjectWithBitmapArray.Items[I]).myBitmap);
        myImageList.Add(xBitmap, nil);
    end;
    PictureComboBox1.ImageList := myImageList;
    PictureComboBox1.Invalidate;
    PictureComboBox1.Refresh;

But I just get an empty list :-(

Any ideas what I'm missing?

Thanks,

James
ASKER CERTIFIED SOLUTION
Ephraim Wangoya
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros