Mozes koristiti niz pointera tipa TLabel (ako znas koliko ces otprilike imati tih labela):
TLabel *pNizLabela[10];
... i kasnije kreiras dinamicki po zemlji, dodeljujes osobine, dogadjaje:
pNizLabela[0] = new ...
Malo napredniji nacin bi bio koriscenjem listi, recimo STL listi, na primer /netestirano/:
--- H ---
Code:
// ...
#include <vector>
using namespace std;
// ...
public:
std::vector<TLabel*> VektorLabela;
// ...
--- CPP ---
Code:
// ...
#include <vector>
using namespace std;
// ...
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
VektorLabela.push_back( new TLabel(this) );
VektorLabela.push_back( new TLabel(this) );
VektorLabela[0]->Parent = this;
VektorLabela[0]->Left = 50;
VektorLabela[0]->Top = 50;
VektorLabela[0]->Caption = "Tekst 1";
VektorLabela[1]->Parent = this;
VektorLabela[1]->Left = 300;
VektorLabela[1]->Top = 300;
VektorLabela[1]->Caption = "Tekst 2";
}
// ...
Jedinstveni vektor za sve komponente, ne samo za TLabel bi se mogao ovako kreirati:
std::vector<TComponent*> VektorKomponenti;
... a trebalo bi da mozes upotrebiti i TList iz samog VCL-a.
Ima vise nacina, na tebi je da procenis sta ti najbolje odgovara.