This documentation is archived and is not being maintained.

ScrollableControl.AutoScroll Property

Gets or sets a value indicating whether the container enables the user to scroll to any controls placed outside of its visible boundaries.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

<LocalizableAttribute(True)> _
Public Overridable Property AutoScroll As Boolean
Dim instance As ScrollableControl
Dim value As Boolean

value = instance.AutoScroll

instance.AutoScroll = value
/** @property */
public boolean get_AutoScroll ()

/** @property */
public void set_AutoScroll (boolean value)

public function get AutoScroll () : boolean

public function set AutoScroll (value : boolean)

Not applicable.

Property Value

true if the container enables auto-scrolling; otherwise, false. The default value is false.

When true, this property enables the container to have a virtual size that is larger than its visible boundaries.

There is currently a limitation in Windows Forms that prevents all classes derived from ScrollableControl from acting properly when both RightToLeft is enabled and AutoScroll is set to Yes. For example, let's say that you place a control such as Panel—or a container class derived from Panel (such as FlowLayoutPanel or TableLayoutPanel)—on your form. If you set AutoScroll on the container to Yes and then set the Anchor property on one or more of the controls inside of the container to Right, then no scrollbar ever appears. The class derived from ScrollableControl acts as if AutoScroll were set to No.

Currently, the only workaround is to nest the ScrollableControl inside another ScrollableControl. For instance, if you need TableLayoutPanel to work in this situation, you can place it inside of a Panel control and set AutoScroll on the Panel to Yes.


AutoScroll maintains the visibility of the scrollbars automatically. Therefore, setting the HScroll or VScroll property to true has no effect when AutoScroll is enabled.

The following code example uses the derived class, Panel. The example evaluates the location of a text box and changes the appearance and behavior of its parent container, the panel control. The example was written under the assumption that you have created instances of a Panel control, TextBox, and Button. Place the text box on the panel so that it overlaps at least one of the panel's edges. Call this subprocedure on the click of a button to see the difference in the panel's behavior and appearance.

Private Sub SetAutoScrollMargins()
    ' If the text box is outside the panel's bounds,
    ' turn on auto-scrolling and set the margin. 
    If (text1.Location.X > panel1.Location.X) Or _
        (text1.Location.Y > panel1.Location.Y) Then
        panel1.AutoScroll = True
        ' If the AutoScrollMargin is set to less
        ' than (5,5), set it to 5,5. 
        If (panel1.AutoScrollMargin.Width < 5) Or _
            (panel1.AutoScrollMargin.Height < 5) Then
            panel1.SetAutoScrollMargin(5, 5)
        End If
    End If
End Sub

private void SetAutoScrollMargins()
    /* If the text box is outside the panel's bounds, 
       turn on auto-scrolling and set the margin. */
    if (text1.get_Location().get_X() > panel1.get_Location().get_X() 
        || text1.get_Location().get_Y() > panel1.get_Location().get_Y()) {

        /* If the AutoScrollMargin is set to less 
           than (5,5), set it to 5,5. */
        if (panel1.get_AutoScrollMargin().get_Width() < 5 
            || panel1.get_AutoScrollMargin().get_Height() < 5) {
                panel1.SetAutoScrollMargin(5, 5);
} //SetAutoScrollMargins

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0