wxGrid resizable
wxGrid resizable
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?
-
- Super wx Problem Solver
- Posts: 426
- Joined: Mon May 29, 2006 10:50 pm
- Location: Jena, Germany
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 );
OS: Windows XP Home, Compiler: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp
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 );
-
- Knows some wx things
- Posts: 43
- Joined: Wed Jan 16, 2008 9:06 am
- Location: Cape Town, SA
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);