在FastReport 5中调整对象位置/尺寸

时间:2015-01-14 18:53:40

标签: delphi fastreport

我需要移动一些备忘录对象,并在生成报告时调整波段的高度。我在脚本中添加了以下内容:

procedure MasterDataOnBeforePrint(Sender: TfrxComponent);
begin
  if (DRID = <TRAN_DETAIL."REFERENCEID">) then
  begin
    txChargeDate.Top := 0;
    txChargeDesc.Top := 0;
    txChargeQuant.Top := 0;
    txChargeAmt.Top := 0;

    txDRInfo.Visible := false;
    txDRDesc.Visible := false;

    MasterData.Height := 0.25;
  end
  else
  begin
    MasterData.Height := 0.65;

    txChargeDate.Top := 0.4;
    txChargeDesc.Top := 0.4;
    txChargeQuant.Top := 0.4;
    txChargeAmt.Top := 0.4;

    txDRInfo.Visible := true;
    txDRDesc.Visible := true;
  end;
  DRID := <TRAN_DETAIL."REFERENCEID">;
end;

基本上,如果当前行项目与前一个行项目具有相同的ReferenceID,那么我不希望打印txDRInfo和txDRDesc。我也不希望有一个很大的空间来展示他们本来会去的地方。因此,我检查参考ID是否已更改并移动项目并隐藏不打印的文本。

问题在于虽然这是在BeforePrint事件中,但我对位置或大小所做的任何更改都会影响所有订单项,而不仅仅是事件正在查看的订单项。

使用Delphi 2007和FastReport VCL 5可以解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

我想出了一个更好的方法来做到这一点。我发现如果一个儿童乐队变得不可见,你仍然可以有任何打印的孩子。所以,我从Master Data乐队中取出所有内容并将它们移到2个子乐队中:

Master Band (Height = 0)
  Child Band 1 with stuff to hide; PrintChildIfInvisible = true
    Child Band 2 with stuff to always show

然后在打印前的儿童乐队1中,我只是检查它是否应该隐藏。