Please do not add a Bitmap in the OnGetCellAppearance event. When using the grid dynamically you should return the TTMSFMXBitmapGridCell cell type in the OnGetCellClass event and use the OnGetCellProperties event to assign the bitmap to the bitmap property of the TTMSFMXBitmapGridCell
I want to remember you what say the manual about OnGetCellProperties:
<div title="Page 24">
<div>
<div>
<p><span style="font-size: 11.000000pt; font-family: 'Helvetica'; font-weight: 700">OnGetCellProperties</span><span style="font-size: 11.000000pt; font-family: 'ArialMT'">: Event called to apply additional properties dynamically to the cell.
Through this event, properties can be applied that are unique per column, row or cell. This event
is called simultaneously with the OnGetCellAppearance, but to keep a clean overview it is
recommended to apply all non-cell visual related properties through this event.
There is a difference between applying additional properties to existing cells and creating cells by adding data through the various amount of helpers such as the AddBitmap call. The AddBitmap call is to add a bitmap grid cell in the underlying data structure. The AddBitmap call should already be executed once for every cell, before the OnGetCellProperties event is called, of course the code you are using to align the bitmap is correct but the code will not be executed unless the cell is a TTMSFMXBitmapGridCell which is added in your code after the align code is called. To solve this issue you need to either use AddBitmap outside of any grid event, or specify the type of cell manually and use a Bitmap.LoadFromFile or a Bitmap.Assign inside the OnGetCellProperties.
I understand. I need to traverse all the rows, after I load the data, calling AddBitmap.
Ok.
One more question. I want to change the bitmap showed on the cell, as response to a click of the user. Really I need to change the underlying data, but....
for change the bitmat, need I free the current instance of the bitmap previously?
If so, this means that every cell has a copy of the bitmap on the associated TTMSFMXBitmapContainer component, instead a reference to this bitmap.
And if so, is not to be more reasonable, forget this BitmapContainer component and for every row, insert a bitmap in a TField of the Dataset?
You can use the OnCellBitmapClick or OnCellClick event and change the bitmap with AddBitmap or when use dynamically set af flag which cell had changes, reload the grid with UpdateGrid and then use the LoadFromFile or Assign of the previously loaded grid cell in the OnGetCellProperties. You can also change and access the bitmap with the Bitmaps property or BitmapNames property when combinee with a BitmapContainer