ControlPaint.DrawBorder Method

Definition

Draws a border on a button-style control.

Overloads

DrawBorder(Graphics, Rectangle, Color, ButtonBorderStyle)

Draws a border with the specified style and color, on the specified graphics surface, and within the specified bounds on a button-style control.

DrawBorder(Graphics, Rectangle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle)

Draws a border on a button-style control with the specified styles, colors, and border widths; on the specified graphics surface; and within the specified bounds.

DrawBorder(Graphics, Rectangle, Color, ButtonBorderStyle)

Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs

Draws a border with the specified style and color, on the specified graphics surface, and within the specified bounds on a button-style control.

C#
public static void DrawBorder(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color color, System.Windows.Forms.ButtonBorderStyle style);

Parameters

graphics
Graphics

The Graphics to draw on.

bounds
Rectangle

The Rectangle that represents the dimensions of the border.

color
Color

The Color of the border.

style
ButtonBorderStyle

One of the ButtonBorderStyle values that specifies the style of the border.

Examples

The following code example demonstrates the use of one of the DrawBorder3D methods. To run this example, paste the following code in a form that imports the System.Windows.Forms and System.Drawing namespaces. Ensure the form's Paint event is associated with the event handler in this example.

C#
// Handle the Form's Paint event to draw a 3D three-dimensional 
// raised border just inside the border of the frame.
private void Form1_Paint(object sender, PaintEventArgs e)
{

    Rectangle borderRectangle = this.ClientRectangle;
    borderRectangle.Inflate(-10, -10);
    ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, 
        Border3DStyle.Raised);
}

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

DrawBorder(Graphics, Rectangle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle)

Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs

Draws a border on a button-style control with the specified styles, colors, and border widths; on the specified graphics surface; and within the specified bounds.

C#
public static void DrawBorder(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color leftColor, int leftWidth, System.Windows.Forms.ButtonBorderStyle leftStyle, System.Drawing.Color topColor, int topWidth, System.Windows.Forms.ButtonBorderStyle topStyle, System.Drawing.Color rightColor, int rightWidth, System.Windows.Forms.ButtonBorderStyle rightStyle, System.Drawing.Color bottomColor, int bottomWidth, System.Windows.Forms.ButtonBorderStyle bottomStyle);

Parameters

graphics
Graphics

The Graphics to draw on.

bounds
Rectangle

The Rectangle that represents the dimensions of the border.

leftColor
Color

The Color of the left of the border.

leftWidth
Int32

The width of the left border.

leftStyle
ButtonBorderStyle

One of the ButtonBorderStyle values that specifies the style of the left border.

topColor
Color

The Color of the top of the border.

topWidth
Int32

The width of the top border.

topStyle
ButtonBorderStyle

One of the ButtonBorderStyle values that specifies the style of the top border.

rightColor
Color

The Color of the right of the border.

rightWidth
Int32

The width of the right border.

rightStyle
ButtonBorderStyle

One of the ButtonBorderStyle values that specifies the style of the right border.

bottomColor
Color

The Color of the bottom of the border.

bottomWidth
Int32

The width of the bottom border.

bottomStyle
ButtonBorderStyle

One of the ButtonBorderStyle values that specifies the style of the bottom border.

Examples

The following code example demonstrates the use of one of the DrawBorder3D methods. To run this example, paste the following code in a form that imports the System.Windows.Forms and System.Drawing namespaces. Ensure the form's Paint event is associated with the event handler in this example.

C#
// Handle the Form's Paint event to draw a 3D three-dimensional 
// raised border just inside the border of the frame.
private void Form1_Paint(object sender, PaintEventArgs e)
{

    Rectangle borderRectangle = this.ClientRectangle;
    borderRectangle.Inflate(-10, -10);
    ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, 
        Border3DStyle.Raised);
}

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10