Hello!
Why don't you declare a static array and assign the instances of your form at startup?
Delphi-Quellcode:
...
Type
TForm1 = Class(TForm)
Label1 : TLabel;
Label2 : TLabel;
Label3 : TLabel;
Label4 : TLabel;
....
Procedure FormCreate(Sender: TObject);
Procedure Button1Click(Sender: TObject);
Private
Labels : Array[1..4] Of TLabel;
End;
....
Procedure TForm1.FormCreate(Sender: TObject);
Begin
Labels[1] := Label1;
Labels[2] := Label2;
Labels[3] := Label3;
Labels[4] := Label4;
End;
Procedure TForm1.Button1Click(Sender: TObject);
Var
i : Integer;
Begin
For i := Low(Labels) To High(Labels) Do
Labels[i].Visible := False;
End;
As a small example - it is mostly equal for TEdit, except the type.
Regards
Muetze1