Delphi XE2 Firemonkey - 设置网格显示颜色和对齐方式
我正在努力为 Delphi Firemonkey 中的 TGrid 分配样式。所需的样式非常基本(即对齐列中的文本和每个值的颜色)。
对于背景,我创建了一个 TGrid,设置行数(例如 200),并添加列数(在本例中为 3)。这些列已标记为“代码”、“公司”和“余额”。由于网格不包含值(如 TStringGrid),我可以通过“GetValue”方法(在其中从外部源检索数据)设置显示值。 - 结果是一个快速的列表,并且能够处理大量数据,缺点是我无法在运行时格式化设计......
我想我可能必须使用“样式”;这是 FM 中的新内容。但是,如果是这种情况,我不确定如何引用该单元格,因为它并不真正存在,因为它是在需要绘制时通过 GetValue 方法绘制的?
任何帮助表示赞赏, 问候 伊恩.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ray Konopka 的博客可能会对您有所帮助:
http://www.raize.com/Articles/FmxStringGridCellFonts.asp
您可以通过为列创建 OnApplyStyleLookup 事件来将样式应用到列,但要设置字体样式和颜色等,您需要仍然需要为 TTextCell 本身实现 OnApplyStyleLookup。
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.
我在 Stackoverflow 上发布了一个非常类似的查询,然后找到了一个可行的解决方案,我在此处添加了
带有实时绑定的 firemonkey 移动网格 - 在运行时更改 TextCell 文本颜色 XE5
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