Is picture.fromData unretained?

I used the EddiesElectronics database for some experiments with database communication and table handling. I wanted to display the contained customer images in a listbox. So when adding a row, I used the celltag, read the variant value into a memoryblock, created a picture with picture.fromData and put this into the celltag.
I added a Textpaint event to the listbox where I read the image from the celltag of the appropriate column and used Graphics.DrawPicture to paint them.

That worked, but not good. Many of the images only displayed their half, the lower part often missing or gray.
I put a debugger stop into the celltag add and examined the images: Perfect!
I did so when I read them: Garbled!

I could fix this by using the variant as the celltag and creating the image during the textpaint event. Anyway, the images fading makes me believe they are not retained when one uses Picture.FromData. Could it be? Or is there another possible reason they behaved that way?

First I would draw images in the CellBackgroundPaint and not in the CellTextPaint event. Secondly: without code…

Thanks, Eli.

  1. Why? Is there a bigger timeslot available in the background paint event? I have a graphics object available, which means I have a view I can fill with any content I want. It works, and I want the images instead of any text. This way I can still have a custom listbox background undisturbed from the foreground cell paint. (Not meaning to reject your proposal, I just wonder if there is any reason to do so except for tradition.)

  2. Well, I have it fixed and I don’t want to revert to older code. Take it more as a theoretical question, maybe towards the engineers or anyone who experienced similar things.