我们刚刚从 Delphi 2010 升级到 XE4,并第一次使用 FireMonkey,所以在黑暗中摸索着尝试弄清楚它是如何工作的。
根据不久前的查询,我试图让 TGrid 组件中的各个单元格根据某些规则以不同的方式显示。我已经完成了 Mike Sutton 发布的有用代码:
Firemonkey Grid Control - Styling a Cell based on a value (via the OnGetValue function call)
我必须进行一些更改才能使其在 XE4 中编译;运行代码时一切看起来都正常,除了:
- FontFill 无法识别,因此暂时将其删除。
- 字体样式根本没有改变,无论如何它都会显示为默认样式。
相关代码(其余部分与上面的链接差不多):
Procedure TFinancialCell.ApplyStyle;
var
T: TFMXObject;
begin
inherited;
ApplyStyling;
end;
Procedure TFinancialCell.ApplyStyling;
begin
// If IsNegative then
// FontFill.Color:=claRed
// else
// FontFill.Color:=claBlack;
Font.Style:=[TFontStyle.fsItalic];
If IsImportant then
Font.Style:=[TFontStyle.fsBold]
else
Font.Style:=[];
If Assigned(Font.OnChanged) then
Font.OnChanged(Font);
Repaint;
end;
IsImportant 标志已正确设置,因此这似乎不是问题。
对此的任何帮助将不胜感激。对于我可能错过的任何愚蠢的事情提前表示歉意。
最佳答案
那篇文章基本上已被我的 FireMonkey 指南网站 http://monkeystyler.com/guide/Category:Grids 中的一些内容所取代。
从 XE3 开始,如果您想修改内容,您需要从 StyledSettings 属性中删除相应的项目,
StyledSettings := StyledSettings - [TStyledSetting.ssStyle, TStyledSetting.ssFontColor]
等等
要更改字体颜色,请使用 FontColor 属性
关于Delphi XE4 Firemonkey 网格控件 - 单独设置单元格样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16477985/