Create a Cell with a Button and a image inside.

In Firemonkey, every component can contain another component.

Normally I use an image inside a Button, and disable the HitTest property of the Image to allow the button to respond to the event OnClick.

Now I want to include a Button of this inside a Cell. I found this in the PDF documentation:
	<div title="Page 38">
		<div>
			<div>
				<p><font face="Courier New, Courier, mono" size="2">TTMSFMXContainerGridCell

Inherits from TTMSFMXGridCell and adds the capability of adding a control reference to the
cell.


The controls can be set to a container cell via the property: TMSFMXGrid.CellControls[Col,Row:
Integer]: TFMXObject


To remove a control from a cell, set TMSFMXGrid.CellControls[Col,Row] to nil. 

But I can't understand many things: 

 Can't I set a column with this characteristic? Shall be assigned Cell by Cell?

I is the second option, in which event handler of the grid shall be the all to this methods?

Thanks in advance!





The retrieval of a Control in a cell is done with the OnGetCellControl event:


procedure TForm1.TMSFMXGrid1GetCellControl(Sender: TObject; ACol,
  ARow: Integer; var AControl: TFmxObject);
var
  img: TImage;
begin
  AControl := TButton.Create(TMSFMXGrid1);
  img := TImage.Create(AControl);
  img.HitTest := False;
  img.Align := TAlignLayout.Client;
  img.Bitmap.LoadFromFile('MyImage.png');
  AControl.AddObject(img);
end;

The CellControls property is a helper property to add a control to a specific Col and Row. The property and the event have the same purpose

The example, is working well, I think, but to handle the click on this button, is there any event handler of the grid or should I assign a delegate handle to the on the fly button?

The grid can't know you create a clickable button here, you could have created any other type of control here, hence, the grid does not have a click event handler for this custom control you create and you should as such assign the event handler to the created button, i.e. (AControl as TButton).OnClick := ...

I'm having troubles with this solution.
For a resultset of 114 rows, with one button on the most left column, the grid becomes as slow that is not usefull. 

This is unfortunately a FireMonkey issue. The grid allows to embed other controls which consume a lot of drawing time. It is the hierarchy of all those levels of components that is causing performance issues.

This is not true. I'm sorry.  Before this moment I'm using TTreeView and TLisView components in substitution of Grids. Each row in this components are a composition of controls inside a TStyleBook component.  

I'm inserting thousand and thousand of Lines, each one with at least 4 buttons with his embedded image, and some TEdits  and more than 20 labels.

This are a lot of components for each line,  and they works well.  

The cause of the slow edit and navigation in TTMSFMXLiveGrid, must be other.