ScrollableControl.AutoScroll Property
Assembly: System.Windows.Forms (in system.windows.forms.dll)
[LocalizableAttribute(true)] public: virtual property bool AutoScroll { bool get (); void set (bool value); }
/** @property */ public boolean get_AutoScroll () /** @property */ public void set_AutoScroll (boolean value)
public function get AutoScroll () : boolean public function set AutoScroll (value : boolean)
Property Value
true if the container enables auto-scrolling; otherwise, false. The default value is false.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.
void 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 || text1->Location.Y > panel1->Location.Y ) { panel1->AutoScroll = true; /* If the AutoScrollMargin is set to less than (5,5), set it to 5,5. */ if ( panel1->AutoScrollMargin.Width < 5 || panel1->AutoScrollMargin.Height < 5 ) { panel1->SetAutoScrollMargin( 5, 5 ); } } }
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()) {
panel1.set_AutoScroll(true);
/* 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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.