Drawing on Scrollable Containers

Creating a scrollable container is straightforward, since the control class inherits from System.Windows.Forms.ScrollableControl. This class exposes several useful properties

Scrollable Forms

It is possible to make the main form a scrollable container, but there is a problem with adding scroll bars and a status bar: the scroll bars will be added below the status bar. This means that the status bar could be scrolled out of view. This is not the normal behaviour for a status bar.

Adding a Scrollable Panel

The next attempt is to add the status bar, then add a scrollable panel whose docking is set to full. Drawing to this panel has problems because the DisplayRectangle will always be the same as the ClientRectangle, so the scroll bars will never appear, unless additional controlls are added to the panel.

If this panel is undocked, then the scroll bars will hide the status bar.

Adding Another Panel

The final attempt is to add a new panel to the scrolling panel. Set the size of this panel to the size of the desired drawing area. The DisplayRectangle will be set to the size of this panel. Scroll bars will appear whenever the client rectangle is smaller than the panel. Be sure to send the status bar and toolbar to the back, so that they are behind the scrolling panel.

Scroll Increments

Line Scroll

The size of the line scroll is 5 pixels.

Page Scroll

The size of the page scroll is equal to the size of the client rectangle.