Page 1 of 1

wxGrid resizable

Posted: Mon Jan 28, 2008 6:45 pm
by dentiol
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?

Posted: Mon Jan 28, 2008 10:33 pm
by clyde729
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:

Code: Select all

    wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
    topSizer->Add( grid,
                   1,
                   wxEXPAND );

    SetAutoLayout(true);
    SetSizer( topSizer );

    topSizer->Fit( this );

Untested for wxDialog, but it should work, too.

Posted: Mon Jan 28, 2008 10:54 pm
by dentiol
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:

Code: Select all

    wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
    topSizer->Add( grid,
                   1,
                   wxEXPAND );

    SetAutoLayout(true);
    SetSizer( topSizer );

    topSizer->Fit( this );

Untested for wxDialog, but it should work, too.
Already done but doesn't make that trick. All is resizable but wxGrid remains static.

Posted: Tue Jan 29, 2008 7:50 am
by homerjaysimpson
grid->Fit() worked for me (and sizers, of course).

Posted: Tue Jan 29, 2008 3:06 pm
by dentiol
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);
This doesn't work for me.

Posted: Sun Feb 03, 2008 11:01 am
by dentiol
Nobody ?