So as the title says, I would like to clean a wxPanel; meaning, erasing every child it may have. Then I would like to assign it a new sizer with and new "children". Finally I would like to update the view.
This is the code I use:
Code: Select all
//page is the panel
page->DestroyChildren();
fgs = new wxFlexGridSizer(0,2,1,1);
fgs->AddGrowableCol(1);
fgs->Add( new wxStaticText(page,wxID_ANY,wxT("Name :")));
fgs->Add( new wxStaticText(page,wxID_ANY,wxT("Test Failure")),1,wxEXPAND,0);
if(condition)
{
fgs->Add( new wxStaticText(page,wxID_ANY,wxT("Level :")));
fgs->Add( new wxStaticText(page,wxID_ANY,wxT("Critical Failure")),1,wxEXPAND,0);
}
page->SetSizer(fgs);
page->Refresh();
I tried to replace the Refresh method by Update, but the result was the same, meaning, like when they were actually not called at all.
So does DestroyChildren eliminates previous sizers as well?
Could someone explain what I am doing wrong?
Thank you