简体   繁体   English

如何用delphi代码编写“ fastreport band”事件

[英]How to write events of “fastreport band” in delphi code

I have masterdata band in my fastreport. 我的fastreport中有masterdata带。 I can write code on "masterdata After print" in pascal script, but i want to know is there a way to write this code in main delphi form. 我可以在pascal脚本中在“打印后的masterdata”上编写代码,但是我想知道是否有一种以主要delphi形式编写此代码的方法。

Pascal script: Pascal脚本:

procedure MasterDataOnAfterPrint(Sender : TfrxComponent) 
begin
   Sup_Page.Text := 'Cont on Page ' + IntToStr(<Page> + 1);
end;

You have different options to interfer your report while printing. 您有不同的选择来干扰打印时的报告。
You might use the events AfterPrint and/or BeforePrint which will provide the component as parameter for every time it will be printed. 您可以使用事件AfterPrint和/或BeforePrint ,它们将在每次打印时将组件作为参数提供。
If you want to access another component then the one which is provided in the events, you can use FindComponent delivering the component for the page actually printed. 如果要访问事件中提供的另一个组件,则可以使用FindComponent为实际打印的页面提供该组件。
To access functions within the report you can call Calc with the functions name as parameter . 要访问报表中的函数,您可以使用函数名称作为参数调用Calc
An other option depending on your demands is to use the GetValue event which, will be called every time a variable is evaluated, providing the name of the variable and a var parameter for the value, which will enable you to return the value you like. 根据您的需求,另一个选择是使用GetValue事件,该事件在每次评估变量时都会调用,提供变量的名称和该值的var参数,这将使您能够返回所需的值。
A short example might be useful: 一个简短的示例可能会有用:

procedure TFormOrDM.frxReport1AfterPrint(Sender: TfrxReportComponent);
begin
  // if Sender is TfrxMasterdata then  // Filter out all Masterdatasets
  if Sender.Name = 'Masterdata1' then // Filter out a specific Masterdatasets
  begin
    TFrxMemoView(frxReport1.FindComponent('Sup_Page')).Text := 'Cont on Page ' + FloatToStr(frxReport1.Calc('<Page>') + 1);
  end;
end;

procedure TFormOrDM.frxReport1BeforePrint(Sender: TfrxReportComponent);
begin
  // Another place you might use to acsess components
end;

procedure TFormOrDM.frxReport1GetValue(const VarName: string; var Value: Variant);
begin
  if VarName = 'myValue' then // own variable defined in the report
    Value := 'Cont on Page ' + FloatToStr(frxReport1.Calc('<Page>') + 1);
end;

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM