在控件周围绘制边框时,如何设置颜色的厚度?



我以前就这样用过它,它画了一个边框,但是很薄:

ControlPaint.DrawBorder(e.Graphics, pictureBox2.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);

然后我决定把它放在一个方法,但不确定如何设置厚度?

private void DrawControlBorder(PaintEventArgs Painteventargs, Control Control, Color Color, int Thickness)
{
ControlPaint.DrawBorder(Painteventargs.Graphics,
Control.ClientRectangle,
Color,
ButtonBorderStyle.Solid);
}

使用正确的重载。然后代码看起来像这样:

Color color = Color.Red;
ButtonBorderStyle style = ButtonBorderStyle.Solid;
int width = 5;
Control control = pictureBox2;
ControlPaint.DrawBorder(e.Graphics,
control.ClientRectangle,
color,
width,
style,
color,
width,
style,
color,
width,
style,
color,
width,
style
);