3

我想在运行时添加一些组件。我使用 C++ Builder XE 7 和 vcl。如何在运行时将组件添加到 Form 类?那可能吗?

4

1 回答 1

2

我找到了解决方案。谢谢你。这是一个例子:

__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;  
}
于 2014-12-20T23:16:46.400 回答