Gets or sets the size of the auto-scroll margin.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The auto-scroll margin is the distance between any child controls and the edges of the scrollable parent control. The size is added to the size of any child controls contained in the scrollable control to determine whether or not scroll bars are needed. The property is evaluated when the parent scrollable control is resized or the individual child controls are brought into view, and is used to determine if scroll bars must be displayed. Docked controls are excluded from the calculations that determine if scroll bars must be displayed.
If a docked control's Dock property is set to DockStyle.Fill, the control fills the parent scrollable control and the docked control is ignored when using the to determine whether scroll bars are needed.
If the distance from the edge of a child control to the parent scrollable control is less than the value assigned to the property and the AutoScroll property is set to true, the appropriate scroll bar is displayed.
We recommend, when docking controls within a scrollable control, that you add a child scrollable control, such as a Panel, to contain any other controls that might require scrolling. You should add the child Panel control to the scrollable control and its Dock property set to DockStyle.Fill and its AutoScroll property set to true. You should set the AutoScroll property of the parent scrollable control to 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 requires that you have created an instance 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 function on the click of a button to see the difference in the panel's behavior and appearance.