[英]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.