Name

ScrollableControl

Synopsis

This is the base class for controls that support automatic scrolling. This includes ContainerControl (and its subclasses such as UserControl) and Panel.

To enable scrolling, you set the AutoScroll property. You can then specify the AutoScrollMinSize. If the control is made smaller than the AutoScrollMinSize, scrollbars are displayed. Alternatively, if any child controls are found within AutoScrollMargin pixels of the edge of its visible area, the scrollbars will also be shown.

You can set or retrieve the current AutoScrollPosition. Note that when you retrieve the position, it comes back as {-x,-y}, whereas when you set it, you must specify {x,y}.

As the AutoScrollPosition is changed, the window content is automatically blitted into the new position, child controls are offset by the appropriate amount, and any newly revealed parts of the control are invalidated for repaint. While this is the most efficient repaint scheme, it is not necessarily ideal for all applications. As an alternative, you can create and manage your own ScrollBar controls.


public class ScrollableControl : Control {

// Public Constructors

   public ScrollableControl();

// Protected Static Fields

   protected const int ScrollStateAutoScrolling;  // =1

   protected const int ScrollStateFullDrag;  // =16

   protected const int ScrollStateHScrollVisible;  // =2

   protected const int ScrollStateUserHasScrolled;  // =8

   protected const int ScrollStateVScrollVisible;  // =4

                  // Public Instance Properties public ...

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.