Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create dynamically component?

Status
Not open for further replies.

nesrine

Programmer
Apr 18, 2008
1
TN
If I want create dynamically components, the number of components depending on an int variable, how to do it?
 

This example creates 5 buttons on Form1

Code:
for (int i = 1; i <= 5; i++) {
     TButton *newButton = new TButton(Form1);
     newButton->Parent = Form1;
     newButton->Caption = &quot;Button &quot; + IntToStr(i);
     // Set other properties, such as Top, Left...
     }
Something like this will work, of course it depends on the component, some require extra things in their constructor. [pc3]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top