TDBAdvGrid PictureStretch for Images from ImageLis


I use a TDBAdvGrid with a specific column used to display images from an ImageList. I have an ImageList assigned to the GridImages property, the specific column is defined as DataImageField, and the database field contains the correct image index.
The images are displayed, but it seems that the "PictureStretch" property does not work, so the images cannot be stretched.

PictureStretch seems only to work if I use a database field containing an image stored as BLOB. But this is not what I want to do.

Afterwards, I tried to use the OnGetDisplText event to apply an HTML code with an IMG tag to the cell (DataImageField property of the column set to FALSE):

procedure TMyForm.dbgrdTestGetDisplText(Sender: TObject; ACol, ARow: Integer; var Value: string);
   if ACol = 1 then begin
      Value := '<P align="center"><IMG src="idx:' + Value + '" width="15px" height="15px"></P>';

Doing so, the images are displayed, but the width and height identifiers do not take any effect.

Does anyone have an idea either what the correct HTML code is or how to achieve image stretching otherwise?


Imagelist images have a fixed size, specified by ImageList.Width / ImageList.Height.
You could use a bitmapcontainer and generate cell html with references to pictures in this bitmap container.

Thanks for your reply.
How do I create the bitmap container? And how can I reference to it in HTML?
Could you post an example?

Please see this article:

Thanks for the article. PictureContainer works.

Is there also a
way to have a "DataPictureField" similar to "DataImageField" where a
database field (which stores the PictureItem.Name)? So we could avoid
HTML and use Column.PictureStretch property to set stretch mode?

reason of my question is: If stretching is achieved with the "width"
and "height" HTML identifiers, the transparent color seems not to be
consiedred, I have a cyan/blue background. If I remove the width and
height tags from HTML, the background is transparent.

- Image from PictureContainer, set HTML OnGetDisplayText, no shrinking
<P align="center"><IMG src="MYPICTURE"></P>
transparency is ok, but image is too large

- Same image from PictureContainer, set HTML OnGetDisplayText, stretching with HTML identifiers;
<P align="center"><IMG src="MYPICTURE" width="20" height="20"></P>
brings wrong transparency

There is at this time not something like a DataPictureField but this is a useful suggestion that we'll consider for a future update.