Currently in my project I have a panel with things laid out in it like this:

* wxBoxSizer(wxVertical)
	+ wxSearchControl(wxExpand)
	+ wxListControl (wxExpand)
	+ wxBoxSizer(wxHorizontal, wxALIGN\_CENTER)
		- wxButton (wxALL)
		- wxButton (wxALL)

The issue is that when the panel is expanded it creates wasted space underneath where the buttons are and the opposite problem also occurs when the panel is contracted, meaning the buttons are removed from sight completely before contracting the wxListControl which is undesirable behaviour. The desired behaviour would be something like: When expanding I want everything to reach it's 'nice size' then the only thing that would continue to expand is the wxListControl, when contracting the wxListControl should contract first until it hits a minimum size and then the buttons and search control should contract. The following pictures should highlight the issues.

\*\*

Wasted space at the bottom: [http://i.stack.imgur.com/lsXOv.png](https://i.stack.imgur.com/lsXOv.png)

Buttons are mangled: [http://i.stack.imgur.com/U50In.png](https://i.stack.imgur.com/U50In.png)

So here is my code (only edited for the small width, bad naming kept and everything):

```
lbxEntityList = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
                               wxLC_REPORT | wxLC_EDIT_LABELS | wxLC_HRULES,
                               wxDefaultValidator, wxT("Entity List Control")); 

lbxEntityList->AppendColumn("Entities",wxLIST_FORMAT_LEFT, 80);

srchControl = new wxSearchCtrl(this, wxID_ANY, "", wxDefaultPosition,
                               wxDefaultSize);

#ifndef __WXMAC__
    srchControl->ShowSearchButton( true );
#endif

srchControl->ShowCancelButton( false );

btn_RemoveEntity = new wxButton( this, wxID_ANY, wxT("Remove Entity"),
                                wxDefaultPosition, wxDefaultSize, 0);

btn_AddEntity = new wxButton(this, wxID_ANY, wxT("Add Entity"),
                             wxDefaultPosition, wxDefaultSize, 0);

sizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* o = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(srchControl, wxSizerFlags().Expand().Border(wxALL, 10));
sizer->Add( lbxEntityList, wxSizerFlags().Expand().Border(wxALL, 10));

sizer->Add(o, 1, wxALIGN_CENTER, 5);
o->Add( btn_RemoveEntity, 0, wxALL, 5 );
o->Add( btn_AddEntity, 0, wxALL, 5 );

SetSizer( sizer );
Layout();
sizer->Fit(this);

```

The only things I have attempted is constantly trying random different sizers in different configurations with different flags in wxFormBuilder in a vain attempt to get it working, but that always ends fruitlessly. I have looked at several sizer tutorials and the only conclusion I get to is that I need to write my own sizer, I am hoping I am missing something and I won't have to do that.