Alter object positions and band size in script

I need to move around some memo objects and adjust the height of a band while the report is being generated. I added the following to the script:
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;

Basically, if the current line item has the same ReferenceID as the previous line item, then I don't want txDRInfo and txDRDesc to print. I also don't want a big space to show up where they would have been. So, I check if the reference ID has changed and move the items around and hide the text that isn't to be printed.

The problem with this is that although this is in the BeforePrint event, any changes I make to position or size affect ALL line items and not just the one being looked at by the event.

Is there a way around this using Delphi 2007 and FastReport VCL 5?

Comments

  • edited 1:19PM
    CaymanPort wrote: »
    I need to move around some memo objects and adjust the height of a band while the report is being generated. I added the following to the script:
    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;
    

    Basically, if the current line item has the same ReferenceID as the previous line item, then I don't want txDRInfo and txDRDesc to print. I also don't want a big space to show up where they would have been. So, I check if the reference ID has changed and move the items around and hide the text that isn't to be printed.

    The problem with this is that although this is in the BeforePrint event, any changes I make to position or size affect ALL line items and not just the one being looked at by the event.

    Is there a way around this using Delphi 2007 and FastReport VCL 5?

    Never mind, I figured out a better way to do this. I discovered that if a child band is made invisible, you can still have any children it has print. So, I took everything out of the Master Data band and moved them in to 2 child bands:

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

    Then in Child Band 1's before print I just check if it should be made invisible or not.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.