2016-05-09 2 views
1

私のC++ Builderプロジェクトには、TPanelを動的に取得するTFramedVertScrollBox(pnl_art_box)があります。私は "新しい"ものを追加する前に、既存のTPanelをすべてクリアしたいと思っています。C++ builder:TFramedVertScrollBoxからすべての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]); 
} 

Googleでは、私は非常に少ないヘルプしか見つけられず、どれもC++ではありません。

私が間違っていると誰かが私に教えてくれればいいですね。

こんにちはティモTreichel

+0

はあなただけarticlelistpanels /ラベル内のすべての要素を削除し、(ベクトルまたはリスト場合は...)それらをクリアんが試したことがありますか?可能であれば、RemoveObjectを最初に呼び出す必要があります。 'this-> pnl_art_box-> DestroyComponents();'または 'this-> pnl_art_box-> DeleteChildren()を呼び出すことを試みたことがありますか? – Aconcagua

+0

も効果がありません。 ); 'forループの代わりに、後者の方が好きな方はどちらを選ぶのかわからない?これを繰り返し行う場合は、2つのリストの内容が無効になる可能性が高いことに注意してください。 –

+0

古いコンポーネントはまだ' this-> pnl_art_box'にリストされていますので – Aconcagua

答えて

0

私はついにそれを見つけました。 正しいコマンドはされていました:

for(int i = 1; i < this->pnl_art_box->ComponentCount; i++) 
{ 
    this->pnl_art_box->Components[i]->DisposeOf(); 
} 
関連する問題