Problem
I have a wxGrid with many rows (>200) placed inside a wxFlexGridSizer. The problem is that my button below the grid disappears. Same thing with a wxBoxSizer works using the proportion setting.
The result should look like the wxBoxSizer solution.
Is there a way to use a wxFlexGridSizer in such situation?
wxBoxSizer (working)
wxGrid *grid = new wxGrid(this, wxID_ANY);
grid->CreateGrid(0, 2);
grid->SetDefaultRowSize(20);
grid->AppendRows(200);
wxButton *button = new wxButton(this, wxID_ANY, "button");
wxBoxSizer *bsMain = new wxBoxSizer(wxHORIZONTAL);
bsMain->Add(grid, 1, wxALL, 5);
bsMain->Add(button, 0, wxALL, 5);
SetSizer(bsMain);
wxGridSizer (not working)
wxGrid *grid = new wxGrid(this, wxID_ANY);
grid->CreateGrid(0, 2);
grid->SetDefaultRowSize(20);
grid->AppendRows(200);
wxButton *button = new wxButton(this, wxID_ANY, "button");
wxFlexGridSizer *fgsMain = new wxFlexGridSizer(1, 0, 0);
fgsMain->Add(grid, 1, wxALL, 5);
fgsMain->Add(button, 0, wxALL, 5);
fgsMain->AddGrowableRow(0);
fgsMain->AddGrowableCol(0);
SetSizer(fgsMain);
I tried to use AddGrowableRow for both rows, proportion setting, wxEXPAND flag.
There is a similar question here, but the solution is a workaround:
Fitting a big grid (wxGrid) in a dialog (wxDialog)
(Screenshoots are made with wxFormBuilder v3.8.1)


By default,
wxGridwill try to show all of its 200 rows on screen, which won't leave enough place for the button. You may callSetInitialSize()(or specify the initial size when creating the grid in its ctor) to change this.Unrelated to this question, but I strongly advise you to use more readable
wxSizerFlags-based API rather than the oldAdd()overloads. You also shouldn't hardcode the border size in pixels, this is always wrong for some platforms and gets even worse on high DPI displays (and usingwxSizerFlagswould have taken care of this automatically).