简体   繁体   English

Firemonkey:设置tGrid或替代的Grid / List组件的样式(虚拟)

[英]Firemonkey: Styling the tGrid or alternative Grid/List components (Virtual)

I'm trying to create my first app based on FireMonkey, and I hit a wall. 我试图基于FireMonkey创建我的第一个应用程序,但是遇到了麻烦。 The only virtual list control I can find is tGrid. 我可以找到的唯一虚拟列表控件是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? 我知道有tCheckbox列,tImage列等,但是如果我需要ButtonColumn或类似的东西怎么办?

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. 示例:如果行中表示的数据具有“ Error = True”,则应以红色显示。

Has anyone got a similar problem? 有没有人遇到过类似的问题? Or found alternate virtual list/grid components? 还是找到了备用虚拟列表/网格组件? Or even just some tips on use of the tGrid component. 甚至只是有关使用tGrid组件的一些技巧。 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? 另外,请注意,我不认为TGrid支持拖放行吗?

I have looked at Firemonkey version of VirtualTreeView and Firemonkey and large amounts of data 我看过VirtualTreeViewFiremonkey的 Firemonkey版本 以及大量数据

If you look at the sources, TCheckColumn is only 15 code lines. 如果您查看源代码,则TCheckColumn只有15条代码行。 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). 这是一种解决方案,否则您可以在单元格中动态创建一些组件,然后在检查道具时投射子项(TColumn.CellControlByRow()返回TControl,子项就是您在其中放置的内容)。

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. 当您想对行进行“样式化”时,即使您可以在OnPaint Event中进行绘画,我还是建议您编写自己的TColumn类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM