Page 1 of 1

Sizerproblems with wxComboBox

Posted: Fri May 02, 2008 2:49 pm
by phlox81
I am having a dialog, which contains a wxComboBox.

The Dialog is layouted pretty good, so the combobox has the right size.

Now, the combobox shows values from the program, and if they are "longer" then the combobox width, the combobox expands, and breaks the whole layout.

I thought, fine, call SetMaxSize and you're done, but it does not work:

Code: Select all

cbb_filename = new wxComboBox(this, ID_COMBOBOX2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX2"));
	cbb_filename->SetMaxSize(wxSize(130,-1));
So, this code does not effect the combobox size. Its getting bigger then this, also replacing wxSize(...) with GetSize() of the combobox does not help.

So, how can I make this combobox always stay the same size?

phlox

Posted: Sat May 03, 2008 8:25 am
by TrV
Maybe could you try to set the "max" size when constructing the object, replacing "wxDefaultSize".

Could you give the code referring to panel and sizer for this combobox please ?

Re: Sizerproblems with wxComboBox

Posted: Sat May 03, 2008 10:59 am
by lester
cbb_filename->SetMaxSize( wxSize( 130, -1 ) );
cbb_filename->GetParent()->GetSizer()->Layout();

Posted: Sat May 03, 2008 11:12 am
by phlox81
The sizer seems to ignore the max size, if wxEXPAND is in its flags.
Removing this and setting the defaultsize to 130,-1, solved it.