Fitting controls with grid sizers Topic is solved

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
WrongSide
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Jun 19, 2011 4:31 pm

Fitting controls with grid sizers

Post by WrongSide »

Hi there,

I have a frame (wxFrame) and a canvas (wxVScrollWindow) attached to that frame. For that canvas I make a grid sizer (one of the standard grid sizers), and with that sizer I add some controls (actually, buttons) to that canvas. So, I just call the

wxSizerItem* Add(wxWindow* window, const wxSizerFlags& flags)

method of the sizer to add new items on the canvas.

The problem is that the sizer (I actually tried all of the grid sizers) just put the items in a huge single row -- no matter what the with of the canvas is. I know I can specify the number of columns per a row for the wxGridSizer, but what if I don't that number of columns? I mean, what I need is the sizer to decide what number of columns fits in the window's width and then determine the number of rows and then locate my items respectively.

So, the question is: do I need to write my own sizer? Or, is there a way I can just add my items to the sizer so it will compute the number of columns by itself?

Thanks!
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

In wx2.9 there's wxWrapSizer, which I think does what you want.

Regards,

David
Post Reply