wxGrid resizable

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dentiol
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Thu Nov 01, 2007 6:21 pm
Location: B800 - B7FF

wxGrid resizable

Post 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?
clyde729
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Mon May 29, 2006 10:50 pm
Location: Jena, Germany

Post 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.
OS: Windows XP Home, Compiler: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp
dentiol
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Thu Nov 01, 2007 6:21 pm
Location: B800 - B7FF

Post 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.
homerjaysimpson
Knows some wx things
Knows some wx things
Posts: 43
Joined: Wed Jan 16, 2008 9:06 am
Location: Cape Town, SA

Post by homerjaysimpson »

grid->Fit() worked for me (and sizers, of course).
dentiol
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Thu Nov 01, 2007 6:21 pm
Location: B800 - B7FF

Post 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.
dentiol
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Thu Nov 01, 2007 6:21 pm
Location: B800 - B7FF

Post by dentiol »

Nobody ?
Post Reply