How can I add components at run time in C++ Builder XE7

1.1k views Asked by At

I want to add some components at run time. I use C++ Builder XE 7 and vcl. How can I add components to the class Form in run time? Is that possible?

1

There are 1 answers

1
Christopher Kossatz On

I found the solution. Thank you. Here is an example:

__fastcall TForm2::TForm2(TComponent* Owner): TForm(Owner)  
{  
    TButton* b = new TButton(this);  
    b->Parent = this;
    b->Height = 100;  
    b->Width = 100;  
    b->Left = 0;   
    b->Top = 0;   
    b->Caption = "Testing";  
    b->Visible = true;  
    b->Enabled = true;  
}