How to add an event to MasterDetail?
I am trying to print a series of labels. That is no problem. But sometimes I need to print a few blank labels. I can add code inside the report to the MasterData OnPrint event that will do the job. I simply look at a field in my dataset, and if false I make all the memo fields in the MasterData band invisible. The problem is, I have so many reports that I cannot go to each report and add the event manually. I need to do it in Delphi.
I have been trying to 'find' the MasterData component on the report, then to somehow assign an event. something like this
The main problem is that I cannot add the event. I understand that FR events are not like Delphi events - but I cannot seem to work out how to do it.
Any help in this regard will be most welcome.
I have been trying to 'find' the MasterData component on the report, then to somehow assign an event. something like this
.....
        fMasterDataOnBeforePrint:TfrxNotifyEvent;
......
    procedure DoMasterDataOnBeforePrint(Sender: TObject);
      procedure SetReportMasterDataEvent(Report: TfrxReport; stName: string);
      property MasterDataOnBeforePrint: TfrxNotifyEvent read fMasterDataOnBeforePrint write fMasterDataOnBeforePrint;
  end;
procedure TPrintReport.SetReportMasterDataEvent(Report: TfrxReport; stName: string);
var
  db: TfrxMasterData;
begin
  DB := Report.FindObject(stName) as TfrxMasterData;
  if DB <> nil then
      begin
        db.OnBeforePrint :=DoMasterDataOnBeforePrint;
      end;
end; //
This suffers from two problems. First, I have to know the name of the MasterData component. This is usually fixed ('MasterData1'), so it is not a real problem, just not neat.The main problem is that I cannot add the event. I understand that FR events are not like Delphi events - but I cannot seem to work out how to do it.
Any help in this regard will be most welcome.
Comments
here is a sample of adding it to a clean script file.