1

在我的 C++ Builder 项目中,我有一个动态获取 TPanel 的 TFramedVertScrollBox (pnl_art_box)。我想在添加“新”之前清除所有现有的 TPanel。

for(int i = 0; i < this->pnl_art_box->ComponentCount; i++)
{
    // this here is where i dont find any solution ...
    this->pnl_art_box->Components[i]->DestroyComponents(); 
}
for(int i = 0; i < i_article_amount;i++)
{
    this->articlelistpanels[i] = new TPanel(this->pnl_art_box);
    this->articlelistlabels[i] = new TLabel(this);

    this->articlelistlabels[i]->Text = this->articlelist[i].get_name();
    this->articlelistpanels[i]->Align = Fmx::Types::TAlignLayout::MostTop;

    this->articlelistpanels[i]->AddObject(this->articlelistlabels[i]);
    this->pnl_art_box->AddObject(this->articlelistpanels[i]);
}

在谷歌,我只找到了很少的帮助,而且没有一个是 C++ 的;

如果有人能告诉我,当我做错了,那就太好了。

真诚的蒂莫·特雷切尔

4

1 回答 1

0

我终于自己找到了。正确的命令是:

for(int i = 1; i < this->pnl_art_box->ComponentCount; i++)
{
    this->pnl_art_box->Components[i]->DisposeOf();
}
于 2016-05-10T09:58:00.973 回答