Firemonkey:设计 tGrid 或替代网格/列表组件的样式(虚拟)
我正在尝试创建我的第一个基于 FireMonkey 的应用程序,但我遇到了困难。 我能找到的唯一虚拟列表控件是 tGrid。
这个组件非常好,但我不知道如何扩展或自定义它。 我知道有 tCheckbox 列、tImage 列等,但是如果我需要 ButtonColumn 或类似的东西怎么办?
另外,我想根据行所代表的数据的状态来设置行的样式。
示例:如果行中表示的数据具有“Error=True”,则应显示为红色。
有人遇到类似的问题吗?或者找到替代的虚拟列表/网格组件?或者甚至只是一些有关使用 tGrid 组件的技巧。 这些组件在所有数据库应用程序中都非常重要,因此它应该是一个非常常见的请求。
另外请注意,我认为 TGrid 不支持 Drag &行数下降?
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果查看源代码,TCheckColumn 只有 15 行代码。如果您需要创建自己的列后代类,那么这非常简单。
这是一种解决方案,否则您可以在单元格中动态创建一些组件,然后在检查道具时强制转换子组件(TColumn.CellControlByRow() 返回一个 TControl 并且子组件将是您放入其中的组件)。
当您想要“样式”您的行时,我建议您编写自己的 TColumn 类,即使您可以在 OnPaint 事件中进行绘画。
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.