Hiding controls using sizers

You can hide controls contained in sizers the same way you would hide any control, using the wxWindow::Show method.

However, wxSizer also offers a separate method which can tell the sizer not to consider that control in its size calculations. To hide a window using the sizer, call wxSizer::Show. You must then call Layout on the sizer to force an update.

This is useful when hiding parts of the interface, since you can avoid removing the controls from the sizer and having to add them back later.

Note: This is supported only by wxBoxSizer and wxFlexGridSizer.

wxBoxSizer

wxBoxSizer can lay out its children either vertically or horizontally, depending on what flag is being used in its constructor. When using a vertical sizer, each child can be centered, aligned to the right or aligned to the left. Correspondingly, when using a horizontal sizer, each child can be centered, aligned at the bottom or aligned at the top. The stretch factor described in the last paragraph is used for the main orientation, i.e. when using a horizontal box sizer, the stretch factor determines how much the child can be stretched horizontally. The following sample shows the same dialog as in the last sample, only the box sizer is a vertical box sizer now:

\includegraphics{sizer08.eps}

wxStaticBoxSizer

wxStaticBoxSixer is the same as a wxBoxSizer, but surrounded by a static box. Here is a sample:

\includegraphics{sizer09.eps}

wxGridSizer

wxGridSizer is a two-dimensional sizer. All children are given the same size, which is the minimal size required by the biggest child, in this case the text control in the left bottom border. Either the number of columns or the number or rows is fixed and the grid sizer will grow in the respectively other orientation if new children are added:

\includegraphics{sizer10.eps}

For programming information, see wxGridSizer.

wxFlexGridSizer

Another two-dimensional sizer derived from wxGridSizer. The width of each column and the height of each row are calculated individually according to the minimal requirements from the respectively biggest child. Additionally, columns and rows can be declared to be stretchable if the sizer is assigned a size different from the one it requested. The following sample shows the same dialog as the one above, but using a flex grid sizer:

\includegraphics{sizer11.eps}

ymasuda 平成17年11月19日