In a VCL application I need to access all the TControl
children of a TForm
. Children are declared as private TControl
variables and are created in runtime using
I have used the following code:
unit MainForm;
interface
uses
Vcl.Controls, Vcl.Forms, Vcl.StdCtrls, Vcl.ExtCtrls, System.Classes;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
myControl: tControl;
end;
implementation
procedure TForm1.FormCreate(Sender: TObject);
var
NumOfControls: integer;
begin
myControl:= tControl.Create(self);
NumOfControls:= ControlCount;
end;
but NumOfControls
is zero.
Is this normal behavior or I am missing something? If yes, how can I access Controls created during runtime?