简体   繁体   English

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

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

My DBText5 contains 0 or 1 and I would like to format DBText3 depending on DBText5 - I am using code ( How set font properties in calculated field using Digital-Metaphors Report Builder RAP ):我的 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;

Both, DBText3 and DBText5 reside in Detail band. DBText3 和 DBText5 都位于 Detail 带中。 I have tried to put this code in the following events (of course I checked that only one event is active at each given time):我试图将此代码放入以下事件中(当然我检查过每个给定时间只有一个事件处于活动状态):

DBText3.OnPrint
DetailBand.OnBeforePrint
CustomVariableOnDetailsBand.Calculate

But in each case the DBText3 appears bold in all rows of the report.但在每种情况下,DBText3 在报告的所有行中都显示为粗体。 My intention is to make DBText3 bold in only those rows whose hase DBText5=1.我的意图是仅在 hase DBText5=1 的那些行中将 DBText3 设为粗体。 Which event should I use or what other adaptations should I make?我应该使用哪个事件或者我应该进行哪些其他改编?

Digital Metaphors own solution is to use Band.OnBeforePrint https://www.digital-metaphors.com/forums/discussion/9962/conditional-format but Detail.OnBeforePrint is not working form, as I said. Digital Metaphors 自己的解决方案是使用 Band.OnBeforePrint https://www.digital-metaphors.com/forums/discussion/9962/conditional-format但正如我所说,Detail.OnBeforePrint 不是工作形式。

I created a quick text project and confirmed that this works.我创建了一个快速文本项目并确认这有效。

I'm using Report Builder 19, Build 76, and Delphi 10.2.我使用的是 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;

You need to set the style for both the true and false condition.您需要为 true 和 false 条件设置样式。

Since you're using RAP, you can use由于您使用的是 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