【问题标题】:Add space above band in FastReport VCL 5在 FastReport VCL 5 中添加带上方的空间
【发布时间】:2015-01-16 23:53:41
【问题描述】:

我有一个正在处理的发票表单,我使用页眉区域作为主数据(以便发票标题信息出现在每一页上),然后是一个主区域来显示发票的行项目和最后是另一个显示总数的主带(总数以多种货币打印)。我想将第二个主带与第一个主带分开,但我看不到这样做的方法。

PAGE HEADER (with invoice header)
MASTER DATA BAND (with invoice detail)
<need space here>
MASTER DATA BAND (with invoice totals)
FOOTER
PAGE FOOTER

更新: 以下是我的报告中的条带排列方式:

如果我将建议的代码放在 MasterData: Totals OnBeforePrint 中,那么这就是我得到的(我使用 40 而不是 5 以使差异明显):

这是没有代码的样子:

这是我的代码:

procedure TotalsOnBeforePrint(Sender: TfrxComponent);
begin
  if Engine.FreeSpace > Totals.Height + Footer.Height + PageFooter.Height + 40 then
    Engine.CurY := Engine.CurY + 40;  
end;

(我翻转了 if 语句中的符号,否则它几乎永远不会执行。)

【问题讨论】:

    标签: delphi fastreport


    【解决方案1】:

    将空子带添加到主数据带 在 Child 的 OnBeforePrint 事件中使用:

    Child1.Visible := 不是 Totals.Dataset.Eof;

    【讨论】:

    • 我试过这个,但它会导致每个 MasterData 行之间出现一个空白行。现在我知道你可以检查数据集的位置,我将尝试不同的组合。
    【解决方案2】:

    根据@gpi 的评论,我向 MasterData:MasterData 带(技术上是 TariffRemarks 带的子)添加了一个子带(名为 Spacer)。然后,我将以下脚本添加到该 Child Band 的 OnBeforePrint 事件中:

    procedure SpacerOnBeforePrint(Sender: TfrxComponent);
    begin
      Spacer.Visible := MasterData.Dataset.RecNo = MasterData.Dataset.RecordCount - 1;
    end;
    

    这行得通。我不确定为什么 MasterData.Dataset.eof 不起作用,但我认为最后一条记录的 OnBeforePrint 事件在表超过最后一条记录并将 eof 标志设置为 true 之前触发。我想 Recno 是基于 0 的,所以 MasterData.Dataset.Recno = MasterData.Dataset.Recordcount 也不起作用。

    【讨论】:

      【解决方案3】:

      如果详细总带是固定高度,则可以使用带的OnBeforePrint(脚本)。我已经使用了值 5 - 将其设置为您想要的任何间距,然后再打印:

      procedure MasterDataTotalBandBeforePrint(Sender: TfrxComponent);
      begin
        // See if there's room for the band between the bottom of the last
        // band (MasterDataDetail) and the footer and page footer.
      
        if Engine.FreeSpace > MasterDataTotalBand.Height + FooterBand1.Height +
                              PageFooter1.Height + 5 then
          Engine.CurY := Engine.CurY + 5;
      end;
      

      【讨论】:

      • 不幸的是,这并没有达到我想要的效果,因为虽然它在开始打印总计之前放置了一个空格,但它还在每个总计行之间放置了一个空格。
      • @Caynadian:嗯,不。它只会影响乐队本身的定位,除非您将值添加到错误的位置。该事件仅在乐队打印之前立即调用,并且仅在每次打印乐队之前应用。它将带本身向下移动 个单位,但总行保持在它们放置在带上的位置。
      • 我不知道为什么它不起作用。我编辑了我的帖子,向您展示了我的乐队布局以及正在发生的事情以及我正在使用的代码。知道我做错了什么吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多