There is the following class containing database information

TDBSchemaSpec=class(Tcomponent) private FDomains: TComponent; FTables : TComponent; public procedure Setup(); destructor Destroy; override; property Domains: TComponent read FDomains; property Tables : TComponent read FTables; end; 

In an instance of the TDBSchemaSpec class, the TDBSchemaSpec property becomes a container for TTableSpec objects (in a loop over table entries with a list of tables)

  TableSpec:=TTableSpec.Create(DBSchema.Tables); DBSchema.Tables.InsertComponent(TComponent(TableSpec)); 

How to bypass all TableSpec components contained in DBSchema.Tables and get their names if the TTableSpec class has a public Name property?

    1 answer 1

    In the TComponent Class, TComponent is a Components property:

     property Components [Index: Integer]: TComponent 

    You can go through it and display the names of all objects in it. An example (assuming all child components are TTableSpec ):

     for i := 0 to dbSchemaSpec.Tables.ComponentCount-1 do begin if dbSchemaSpec.Tables.Components[i] is TTableSpec then ShowMessage(TTableSpec(dbSchemaSpec.Tables.Components[i]).Name); end;