Search code examples
delphifiremonkeytimagetgrid

How to display a TImage as a background of a TGrid on Firemonkey?


I have a TGrid on a form. I need to display a TImage inside that grid, as it´s background. I know that in Firemonkey framework, controls are containers to other controls. Having that in mind, I dragged the TImage Object to the TGrid Obect using the structure pannel. Now the TImage´s parent is the TGrid object. In design time, it´s fine, I can see the TImage "inside" the TGrid, but when I run the application, the TImage is gone.

Have spent all weekend googling for an answer and despite finding a lot of vcl oriented solutions, and all of them trying to put a TImage inside a TDBGrid or TStringGrid column, I couldn´t find anything that can help me.

Am I using the correct approach?

How can I accomplish my goal?

To test, is very simple:

Just drag a TGrid to a FMX form. Crate a couple of columns inside it. Drag a TImage to the form. Now in the scruture panel, find the TImage Obect and drag it to make it child of the TGrid component. Assign a Bitmap to it, and send it to back.

You will see the image as a background of the grid, but when you run the application, the image disapears.

Thanks.


Solution

  • As suggested by Hans, I´ve inverted the parent/child relationship, making the image, parent of the grid.

    After tunning a litte bit with the Opacity properties of both obects, I managed to get the result I needed.

    Thank you Hans!