c++builderdestroytpanel

c++ builder: dynamically remove all TPanel's from TFramedVertScrollBox


In my C++ Builder Project i have a TFramedVertScrollBox (pnl_art_box) which dynamically gets TPanel's. I want to clear out all existing TPanel's before adding the "new" ones.

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]);
}

At Google i only found very less help and none of them is in C++;

Would be nice, if someone could tell me, when i do wrong.

Sincerely Timo Treichel


Solution

  • I finally found it by myself. The correct command had been:

    for(int i = 1; i < this->pnl_art_box->ComponentCount; i++)
    {
        this->pnl_art_box->Components[i]->DisposeOf();
    }