【发布时间】:2015-09-24 10:24:23
【问题描述】:
我想在运行时将新面板添加到我的表单中,但我遇到的问题是,当它们与顶部对齐时,它们没有按照我创建它们的顺序显示。
我按照这篇文章的提示使用 DisableAlign() 和 EnableAlign() How to dynamically create controls aligned to the top but after other aligned controls? 这适用于我添加的最初四个面板。
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
TPanel * test;
Panel1->DisableAlign();
for(int i = 0; i<4; i++){
test = new TPanel(Panel1);
test->Caption = i;
test->Parent = Panel1;
test->Align = alTop;
}
Panel1->EnableAlign();
}
但是我想在单击按钮时添加另一个面板:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Panel1->DisableAlign();
TPanel * test;
test = new TPanel(Panel1);
test->Caption = 5;
test->Parent = Panel1;
test->Align = alTop;
Panel1->EnableAlign();
}
这出现了:
有没有什么方法可以让对齐做我想做的事情,而不会弄乱顶部设置或不重建整个表单?
【问题讨论】:
标签: delphi c++builder