PictureContainer

I thought I would use the PictureContainer component to hold images generated in code that are then fed to a AdvStringGrid (used like the image catalogue example). I was surprised to discover that the PictureContainer.Items[].Picture property is not a TPicture but a TGraphic! This really messed me up for a few hours (it was 3AM) when I tried to pass a PictureContainer Picture to the StringGrid cell Picture.

Is there any particular reason for this difference in naming? Why not a PictureContainer with Picture items of type TPicture (or a GraphicContainer with Graphic items of type TGraphic?)


When using a TPictureContainer, you actually need to use AddDataPicture instead, using the name that is defined in the TPictureContainer. See below for a sample.




  AdvStringGrid1.PictureContainer := PictureContainer1;
  AdvStringGrid1.AddDataPicture(2, 2, 'MyImage', haCenter, vaCenter);

Ahhhhh!!!!

... except now I can't get the image and the text (filename) to appear together! I can have the image or I can have the text but I can't get them both visible like on the Image Catalogue example. The vaUnderText and vaAboveText move the image in the cell but there is no text.

Then you'll need to use a workaround:



  AdvStringGrid1.CreatePicture(2, 2, False, StretchWithAspectRatio, 0, haCenter, vaCenter).Assign(PictureContainer1.Items[0].Picture);

Now THAT works :-) 

Thanks for the help!

Your welcome!