繁体   English   中英

如何根据 Detail 带中的其他字段有条件地格式化 Detail 带中的 ReportBuilder 字段?

[英]How to conditionally format ReportBuilder field in Detail band depending on the other fields in then Detail band?

我的 DBText5 包含 0 或 1,我想根据 DBText5 格式化 DBText3 - 我正在使用代码( How set font properties in calculated field using Digital-Metaphors Report Builder RAP ):

if (DBText5.FieldValue=1) then begin
  DBText3.Font.Bold := True;
end;

DBText3 和 DBText5 都位于 Detail 带中。 我试图将此代码放入以下事件中(当然我检查过每个给定时间只有一个事件处于活动状态):

DBText3.OnPrint
DetailBand.OnBeforePrint
CustomVariableOnDetailsBand.Calculate

但在每种情况下,DBText3 在报告的所有行中都显示为粗体。 我的意图是仅在 hase DBText5=1 的那些行中将 DBText3 设为粗体。 我应该使用哪个事件或者我应该进行哪些其他改编?

Digital Metaphors 自己的解决方案是使用 Band.OnBeforePrint https://www.digital-metaphors.com/forums/discussion/9962/conditional-format但正如我所说,Detail.OnBeforePrint 不是工作形式。

我创建了一个快速文本项目并确认这有效。

我使用的是 Report Builder 19、Build 76 和 Delphi 10.2。

procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
begin
  if DBText5.fieldvalue = 20  then
    DbText5.Font.Style := [fsBold]
  else
    DbText5.Font.Style := [];
end;

您需要为 true 和 false 条件设置样式。

由于您使用的是 RAP,因此您可以使用

if DbText5.Fieldvalue = 1 then
  DbText5.Font.Bold := true
else
  DbText5.Font.Bold := false; 

暂无
暂无

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

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