如何编写"fastreport band"事件?在delphi代码中 [英] How to write events of "fastreport band" in delphi code
问题描述
我的fastreport中有masterdata波段.我可以在pascal脚本中在打印后的masterdata"上编写代码,但我想知道是否有一种以主要delphi形式编写此代码的方法.
I have masterdata band in my fastreport. 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脚本:
procedure MasterDataOnAfterPrint(Sender : TfrxComponent)
begin
Sup_Page.Text := 'Cont on Page ' + IntToStr(<Page> + 1);
end;
推荐答案
在打印时,您有不同的选择来干扰报告.
您可以使用事件 AfterPrint
和/或 BeforePrint
,它们将在每次打印时将组件作为参数提供.
如果要访问事件中提供的另一个组件,则可以使用FindComponent为实际打印的页面提供该组件.
要访问报表中的函数,您可以使用函数名称作为参数调用 Calc
.
根据您的需求的另一种选择是使用 GetValue
事件,该事件在每次评估变量时都会调用,并提供变量名称和值的var参数,这将使您能够返回您喜欢的值.
一个简短的示例可能会有用:
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.
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.
To access functions within the report you can call Calc
with the functions name as parameter .
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.
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;
这篇关于如何编写"fastreport band"事件?在delphi代码中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!