NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ScrollableControl.AutoScrollMargin

Gets or sets the size of the auto-scroll margin.

[Visual Basic]
Overridable Public Property AutoScrollMargin As Size
[C#]
public Size AutoScrollMargin {virtual get; virtual set;}
[C++]
public: __property virtual Size get_AutoScrollMargin();
public: __property virtual void set_AutoScrollMargin(Size);
[JScript]
public function get AutoScrollMargin() : Size;
public function set AutoScrollMargin(Size);

Property Value

A Size object that represents the height and width of the auto-scroll margin in pixels.

Exceptions

Exception Type Condition
ArgumentException The Height or Width value assigned was less than zero.

Remarks

The auto-scroll margin is used to determine when scroll bars are needed on the control, and where to scroll to when a control is selected. The margin is added around all the controls contained within the scrollable control. If the adjusted border does not contain all the controls, the appropriate scroll bars will be displayed to allow the the controls and the margin to be visible by scrolling the control.

Example [Visual Basic]

The following 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. This example assumes a Panel control, TextBox, and Button have been instantiated. Place the text box on the the panel so that it overlaps at least one of the panel's edges. Call this sub procedure on the click of a button to see the difference in the panel's behavior and appearance.

[Visual Basic]

Private Sub MySub()
   ' 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

See Also

ScrollableControl Class | ScrollableControl Members | System.WinForms Namespace | AutoScroll | SetAutoScrollMargin