Firemonkey: Styling the tGrid or alternative Grid/List components (Virtual)
Asked Answered
M

1

7

I'm trying to create my first app based on FireMonkey, and I hit a wall. The only virtual list control I can find is tGrid.

This component is pretty good, but I can not figure out how to extend or customize it. I get that there is tCheckbox column, tImage column etc, but what if I need a ButtonColumn or something like this?

Also I would like to style a row, based on the state of the data it represents.

An Example: if the data that is represented in the row has "Error=True" it should be displayed in red.

Has anyone got a similar problem? Or found alternate virtual list/grid components? Or even just some tips on use of the tGrid component. These components are pretty essential in all database apps so it should be a pretty common request.

Also just as a note, I don't think the TGrid supports Drag & Drop of rows?

I have looked at Firemonkey version of VirtualTreeView and Firemonkey and large amounts of data

Miler answered 2/11, 2011 at 21:18 Comment(2)
Artis may be I'm a little bit late with this. Im new in embarcadero fire monkey and have a bunch of questions regarding FMX Grid. Could you post your code for styling the the Tcolumn? Thanks JohnShadow
Hi I will post some code when i get back to the computer. I must say though that the solution was not all that elegant in the end. I would probably go for TMS' new table component. My solution was buggy and not easy to maintain.Miler
F
6

If you look at the sources, TCheckColumn is only 15 code lines. If you need to create your own column descendant class it's quite straightforward. This is one solution, otherwise you can dynamically create some components in your cells and then cast the children when checking the props (TColumn.CellControlByRow() return a TControl and the children would be what you have put in there).

As you want to 'style' your row I would suggest you to write your own TColumn class, even if you can do painting in the OnPaint Event.

Formalin answered 3/11, 2011 at 16:19 Comment(2)
Hi thank you for your answer. Creating my own column seems to do the trick. It will of course not show in the column editor, but I can add it using tGrid.AddObject Now that I have control of the column and the cells, it seems easier to do the rest.Miler
If anyone is interested; I solved the styling of cells by overriding the UpdateColumn procedure of TColumn. In this I added a function, similar to GetValue, GetCellStyleLookup, This is published in the grid just like GetValue. So now I can apply a Style (Created with the Style Editor) to any Cell based on the virtual content. I have no idea if this is the best/intended way of doing it, but it works. and given such sparse documentation I don't have time to figure out something else.Miler

© 2022 - 2024 — McMap. All rights reserved.