I have a wxNotebook
with two added pages. Each page uses a wxFlexGridSizer
to manage the various widgets on each page.
The first page has three columns of widgets, the second page only two. The first page is wider than the second page.
The notebook is resized to the size of its widest page (the first one). However, on the second page I would like to have the sizer expand to fill the entire page, too. Instead, it just resizes to fit the widgets on that page.
So my question is: How can I make the sizer of the second page expand to the whole notebook width, which is determined by the width of the first page?
I have tried calling the Layout()
function of the parent wxNotebook
, but that did not help.
Edit:
wxNotebook *notebook = new wxNotebook(this, wxID_ANY);
wxPanel* pageOne = new wxPanel(notebook, wxID_ANY);
wxFlexGridSizer* sizer = new wxFlexGridSizer(3);
wxSizerFlags flags = wxSizerFlags().Align(wxLEFT).Border(wxRIGHT, 5);
wxStaticText* label = new wxStaticText(pageOne, wxID_ANY, wxT("Label 1"));
sizer->Add(label, flags);
label = new wxStaticText(pageOne, wxID_ANY, wxT("Label 2"));
sizer->Add(label, flags);
wxSpinCtrlDouble* value = new wxSpinCtrlDouble(pageOne, wxID_ANY, wxT("50.0"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
sizer->Add(value, flags);
pageOne->SetSizer(sizer);
notebook->AddPage(pageOne, wxT("Page 1"));
wxPanel* pageTwo = new wxPanel(notebook, wxID_ANY);
sizer = new wxFlexGridSizer(2);
flags = wxSizerFlags().Align(wxLEFT).Border(wxRIGHT, 5);
label = new wxStaticText(pageTwo, wxID_ANY, wxT("Label 1"));
sizer->Add(label, flags);
value = new wxSpinCtrlDouble(pageTwo, wxID_ANY, wxT("50.0"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
sizer->Add(value, flags);
pageTwo->SetSizer(sizer);
notebook->AddPage(pageTwo, wxT("Page 2"));
topLevelSizer->Add(notebook);
this->SetSizerAndFit(topLevelSizer);