1 out of 2 rated this helpful - Rate this topic

ScrollableControl.ScrollControlIntoView Method

Scrolls the specified child control into view on an auto-scroll enabled control.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public void ScrollControlIntoView(
	Control activeControl
)

Parameters

activeControl
Type: System.Windows.Forms.Control
The child control to scroll into view.

The AutoScroll property must be set to true, and at least one of the scroll bars, horizontal or vertical, must also be visible, for the ScrollControlIntoView method to have an effect. To make the horizontal and vertical scroll bars visible, the HScroll and VScroll properties, respectively, must be set to true.

If the activeControl parameter is not a child control, no action takes place.

This method may raise the Scroll event.

The following code example enables auto-scrolling for a form, resizes the form, and ensures that a button remains visible after the form is resized. The example requires that you have a Form with a Button named button2 on it.


private void ResizeForm()
{
   // Enable auto-scrolling for the form.
   this.AutoScroll = true;

   // Resize the form.
   Rectangle r = this.ClientRectangle;
   // Subtract 100 pixels from each side of the Rectangle.
   r.Inflate(-100, -100);
   this.Bounds = this.RectangleToScreen(r);

   // Make sure button2 is visible.
   this.ScrollControlIntoView(button2);
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.