0
votes

I am struggling to assign a style to a TGrid within Delphi Firemonkey. Styling required is quite basic (ie. Align the text in a column and colour per value).

For background, I have created a TGrid, set the rows (eg 200), and added the number of columns (3 in this case). The columns have been labeled as "Code", "Company" and "Balance". As the grid does not contain values (like a TStringGrid), I am able to set the display value via the "GetValue" method (where I retrieve data from an external source). - The result is a list that is fast, and able to cope with a lot of data, the downside is I can not format the design at run time...

I am thinking that I may have to use "Styles"; that are new in FM. If this is the case however, I am not sure how I can reference the cell as it does not really exist as it is painted via the GetValue method when it needs to be drawn?

Any help appreciated, Regards Ian.

2
Styling grids isn't something I've attacked yet, but I'll need to in the next couple of weeks for my project and I'll blog about it (and post here) when I do. I suspect at the moment you're using TTextCell/TTextColumn which means you'd need a style called textcellstyle, but then it would apply to all columns, which doesn't sound like what you want. I don't believe there's support to set the stylelookup for an individual column, which means you'll need to create a custom cell/column class. Which I have done and again I'll blog about it. For now read the source for FMX.Grid.pas.Mike Sutton
Thanks Mike; it does sound like I will need to be adding a custom cell/column class; which I guess I will then be able to access/set the text alignment etc... I'll take a look at the .pas source and eagerly await your blog/further info. - Cheers.Ian

2 Answers

0
votes

Ray Konopka's blog might help you here:

http://www.raize.com/Articles/FmxStringGridCellFonts.asp

You can apply a style to a Column by creating the OnApplyStyleLookup event to the column, but to set the font style and color etc you would still need to implement a OnApplyStyleLookup for the TTextCell's themselves too.

0
votes

I posted a very similar query on Stackoverflow and then found a workable solution which I added here

firemonkey mobile grid with livebindings - changing TextCell text color at runtime XE5