0

I have made research of how to dynamically at run time change font color and cell background color, but all solutions are in Delphi code, and cannot be used in C++.

Like this one:

CellCtrl := TColumnAccess( StringGrid1.Columns[ Col ] ).CellControlByRow( Row );

CellControlByRow doesnt exist in FMX C++ Builder. I have tried to use TGrid, but this make the grid very slow when each cell has to be drawn custom in event driven OnDrawxxxx.

There is another solution changing the font color and the cell color in the event OnApplyStyleLookUp, but again the solution in Delphi doesn't exist in C++ Builder, or I don't know how to implement in OnApplyStyleLookUp C++ Builder style.

Any help on this is very much appreciated, since I have been a week in this now.

TLama
  • 75,147
  • 17
  • 214
  • 392
Andersen
  • 9
  • 2
  • Any method which is available in Delphi will also be available in C++. TColumnAccess sounds like a hack I used to get to a protected method. I believe that protected method has now been refactored away. Can you give more details on the conditions under which you want a cell cell colour to change? – Mike Sutton Dec 16 '14 at 13:29
  • As to "not implemented" an example is: TBitmapCodecManager.SaveToStream(Stream, Surf, '.jpg',@saveParams); – Andersen Dec 16 '14 at 18:59
  • As to "not implemented" an example is: Delphi: TBitmapCodecManager.SaveToStream(Stream, Surf, '.jpg',@saveParams); C++ not implemented : Manager->SaveToStream(Stream,Surf,".jpg",params); Im reaching a point of desperation, that cell color is not important - but for your info this to add different row colors at run time, for example uneven rows a slightly different color. Most important is font color of cell text, for example negative text value have the text color red, and positive values green. – Andersen Dec 16 '14 at 19:06
  • I set/change the font color while writing a new text string to the cell. A solution is to get the column object, and handle the event onStyleLookup, or on celldraw - but how to get the cell/column object ? – Andersen Dec 16 '14 at 19:11
  • Setting/changing the font color of a grid cell is one of the most fundamental features in a StringGrid - why do this have to be rocket science to do - and undocumented ? – Andersen Dec 16 '14 at 19:14
  • The trick with FMX grids is to do stuff *inside* the cell objects. Cells are just standard components - usually TEdits. I have an example which does pretty much what you're after at http://monkeystyler.com/guide/Formatting-a-Column-as-Currency (Slightly outdated but most of it should still work or be easily modifiable). – Mike Sutton Dec 17 '14 at 20:48

0 Answers0