ScrollableControl.DockPaddingEdges Class
Determines the border padding for docked controls.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The ScrollableControl.DockPaddingEdges class creates a margin on a given edge or all edges of a docked control. You can set the width of this margin for each individual edge by setting the following properties: Bottom, Top, Left, Right. Alternatively, you can set all the edges to the same width simultaneously by setting the All property. If the size of the control is too large for its container, the control will be resized to fit in the container, minus the specified margin width.
The following code example uses the derived class, Panel. The example docks a button in a panel control and cycles through the ScrollableControl.DockPaddingEdges properties, setting each individually on the click of the button. This code requires that a Panel control and a Button have been instantiated on a form, and a class-level member variable named myCounter has been declared as a 32-bit signed integer. This code should be called on the Click event of the button.
Private Sub SetDockPadding() ' Dock the button in the panel. button1.Dock = System.Windows.Forms.DockStyle.Fill ' Reset the counter if it is greater than 5. If myCounter > 5 Then myCounter = 0 End If ' Set the appropriate DockPadding and display ' which one was set on the button face. Select Case myCounter Case 0 panel1.DockPadding.All = 0 button1.Text = "Start" Case 1 panel1.DockPadding.Top = 10 button1.Text = "Top" Case 2 panel1.DockPadding.Bottom = 10 button1.Text = "Bottom" Case 3 panel1.DockPadding.Left = 10 button1.Text = "Left" Case 4 panel1.DockPadding.Right = 10 button1.Text = "Right" Case 5 panel1.DockPadding.All = 20 button1.Text = "All" End Select ' Increment the counter. myCounter += 1 End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.