wxGrid resizable
Posted: Mon Jan 28, 2008 6:45 pm
I have a wxDialog where I have wxGrid, it works pretty fine except wxGrid stays fixed. Fit() didn't help, is there a way how to make it resizable?
Official forum for the wxWidgets Cross-Platform GUI Toolkit
https://forums.wxwidgets.org/
Code: Select all
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
topSizer->Add( grid,
1,
wxEXPAND );
SetAutoLayout(true);
SetSizer( topSizer );
topSizer->Fit( this );
Already done but doesn't make that trick. All is resizable but wxGrid remains static.clyde729 wrote:Have a look at the grid sample. They are working with the default solution for this problem... sizers. These are the interesting lines of the toplevel window's ctor:
Untested for wxDialog, but it should work, too.Code: Select all
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); topSizer->Add( grid, 1, wxEXPAND ); SetAutoLayout(true); SetSizer( topSizer ); topSizer->Fit( this );
homerjaysimpson wrote:grid->Fit() worked for me (and sizers, of course).
Code: Select all
WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
this->SetSizer(WxBoxSizer1);
this->SetAutoLayout(true);
WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
WxBoxSizer1->Add(WxBoxSizer2, 0, wxALIGN_CENTER | wxALL, 5);
WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Name:"), wxPoint(5,6), wxDefaultSize, 0, wxT("WxStaticText1"));
WxBoxSizer2->Add(WxStaticText1,0,wxALIGN_CENTER | wxALL,5);
name = new wxTextCtrl(this, ID_CTRLNAME, wxT(""), wxPoint(98,5), wxSize(50,19), 0, wxDefaultValidator, wxT("name"));
WxBoxSizer2->Add(name,0,wxALIGN_CENTER | wxALL,5);
grid = new wxGrid(this, ID_GRID, wxPoint(5,44), wxSize(500,357), wxSTATIC_BORDER | wxVSCROLL | wxCLIP_CHILDREN | wxEXPAND);
grid->SetDefaultColSize(30);
grid->SetDefaultRowSize(20);
grid->SetRowLabelSize(50);
grid->SetColLabelSize(25);
grid->CreateGrid(20,3,wxGrid::wxGridSelectCells);
grid->Fit();
WxBoxSizer1->Add(grid,1,wxALIGN_CENTER | wxEXPAND | wxALL,5);
WxBoxSizer1->Layout();
WxBoxSizer1->Fit(this);
WxBoxSizer1->SetSizeHints(this);
Center();
gridFiles->SetColSize(0, 350);
gridFiles->SetColSize(1, 50);
gridFiles->SetColSize(2, 50);