Board index » delphi » how to handle a couple of similar events in only one procedure

how to handle a couple of similar events in only one procedure

By writing an App with a ReportBuilder i've got the following problem:

in principle I want my App to do the following pieve of code

(InvisibleFields is a TStringList, KontonummerPrint is an Event of a
Reporters Data-Komponent, similar to a Quickreport DB-Field

------------------------------------------------------------
procedure TfrmListAnzeige.KontonummerPrint(Sender: TObject);
begin
     if (Invisiblefields <> nil) and
(invisibleFields.IndexOf(Kontonummer.Name) >= 0) then
        kontonummer.Visible := false;
end;
------------------------------------------------------------

My problem is: every DataField komponent I drop on my report creates
on of those Events (eg KontonummerPrint,
InventarnummerPrint . . . .).

Is there any possibility to centralize the handling of those Events in
one procedure ??

anybody out there can solve it ??

 

Re:how to handle a couple of similar events in only one procedure


Quote
lom...@uni-duesseldorf.de wrote:

> By writing an App with a ReportBuilder i've got the following problem:

> in principle I want my App to do the following pieve of code

> (InvisibleFields is a TStringList, KontonummerPrint is an Event of a
> Reporters Data-Komponent, similar to a Quickreport DB-Field

> ------------------------------------------------------------
> procedure TfrmListAnzeige.KontonummerPrint(Sender: TObject);
> begin
>      if (Invisiblefields <> nil) and
> (invisibleFields.IndexOf(Kontonummer.Name) >= 0) then
>         kontonummer.Visible := false;
> end;
> ------------------------------------------------------------

> My problem is: every DataField komponent I drop on my report creates
> on of those Events (eg KontonummerPrint,
> InventarnummerPrint . . . .).

> Is there any possibility to centralize the handling of those Events in
> one procedure ??

> anybody out there can solve it ??

1. Write a general methode like this:

 procedure TfrmListAnzeige.DataFieldPrint(Sender: TObject);
 begin
      if (Invisiblefields <> nil) and
 (invisibleFields.IndexOf(Sender(TDataField(Sender).Name) >= 0) then
         TDataField(Sender).Visible := false;
 end;

2. Assign this methode to the print event of every Component you want.
   if you assign the methode at runtime, you can declare this methode in
the private section of TfrmListAnzeige. If you want to do it at design
time, you have to declare the mehode before the private section. Then
you can assign it with the objectinspector.

Regards Bernd

Other Threads