This article
originally appeared in the Builder.com
Visual Basic e-newsletter. Click
here to subscribe automatically.

If you need to place more controls on a form than you can
display at one time, an option is to create a tabbed interface using the TabStrip control. But sometimes the functions of the
controls don't lend themselves to division among two or more tabs. In this
situation, you can create a scrolling form that lets the user scroll controls
into view.

Start by placing a Picture Box control on the form and
naming it pbOuter.
Then place a second Picture Box within the first one and name it pbInner. This is
important: The second Picture Box must be a child of the first one. You might
want to change the background color of one of the Picture Box controls so it's
easy to tell them apart.

Now you can start placing the form's controls. They all must
be placed within the second Picture Box, pbInner. You can increase the
Picture Box size, both height and width, as needed to accommodate all the
controls. The size of pbOuter
doesn't matter; it will be adjusted in code when the program runs. The size of pbInner should be
as tall as necessary to fit all of your controls, but no wider than the form.
Add a vertical scroll bar on the form itself. Set the scroll bar to the desired
width (the height doesn't matter at this time). Finally, add a horizontal
scroll bar on the form and set its height as desired (the width doesn't
matter).

The remaining action takes place in code. First, put code in
the Form_Resize
event procedure that positions the scroll bars against the right and bottom
edges of the form and sizes pbOuter to fill the remainder of the form:

You also need code in Form_Resize to determine if pbOuter is large
enough to display all of pbInner
without scrolling. In this case, you should hide one or both scroll bars. If
it's not large enough, you need to show the scroll bars and set the scrolling
parameters for the scroll bars.