System.Windows.Forms.ScrollableControl.AutoScrollPosition Property

Gets or sets the location of the auto-scroll position.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point AutoScrollPosition { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

The ScrollableControl.AutoScrollPosition property represents the location of the visible portion of a scrollable control. Use this property to change the portion of the control that is displayed.

When adding controls programmatically to a form, use the ScrollableControl.AutoScrollPosition property to position the control either inside or outside of the current viewable scroll area.

Note:

The System.Drawing.Point.X and System.Drawing.Point.Y coordinate values retrieved are negative if the control has scrolled away from its starting position (0,0). When you set this property, you must always assign positive System.Drawing.Point.X and System.Drawing.Point.Y values to set the scroll position relative to the starting position. For example, if you have a horizontal scroll bar and you set x and y to 200, you move the scroll 200 pixels to the right; if you then set x and y to 100, the scroll appears to jump the left by 100 pixels, because you are setting it 100 pixels away from the starting position. In the first case, ScrollableControl.AutoScrollPosition returns {-200, 0}; in the second case, it returns {-100,0}.

To detect when ScrollableControl.AutoScrollPosition changes, create an event handler for the Control.Paint event, save the old position value in a private variable, and compare the new value to the old value on subsequent Control.Paint events.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0