Re: wx.Panels + BoxSizer

[email protected]
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
> I was wondering whether the Sizers in wx.Net work within
> Panels: I use panels as containers to group widgets (assuming panels are
> suitable to do this (-: ), and each panel has its own Sizer
> ...

Yes, sizers can be used with anything that is derived from wx.Window.  To 
group controls, you can also nest sizers (a sizer within another sizer).

For your code to work, you need to call Window::Fit after setting the sizer
for the Panels.

> Button b1,b2,b3,b4;
> BoxSizer overAll = new BoxSizer(Orientation.wxVERTICAL);
> BoxSizer row1 = new BoxSizer(Orientation.wxHORIZONTAL);
> BoxSizer row2 = new BoxSizer(Orientation.wxHORIZONTAL);
> 
> Panel p1 = new Panel(this);
> b1 = new Button(p1, -1, "Upper left");
> b2 = new Button(p1, -1, "Upper right");
> row1.Add(b1); row1.Add(b2);
> p1.Sizer = row1;

p1.Fit();

> Panel p2 = new Panel(this);
> b3 = new Button(p2, -1, "Botton left");
> b4 = new Button(p2, -1, "Bottom rigth");
> row2.Add(b3); row2.Add(b4);
> p2.Sizer = row2;

p2.Fit()

> overAll.Add(p1); overAll.Add(p2);
> Sizer = overAll;
>...

> Since the example works when the panels are removed, I was wondering
> whether this is correct behavior, or whether I should use the Sizers as
> containers? 

I recommend using sizers as containers but it's no big deal.  This is correct 
behaviour though.


Cheers.





-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.