private void panel1_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics,
this.panel1.ClientRectangle,
Color.LightSeaGreen,//7f9db9
1,
ButtonBorderStyle.Solid,
Color.LightSeaGreen,
1,
ButtonBorderStyle.Solid,
Color.LightSeaGreen,
1,
ButtonBorderStyle.Solid,
Color.LightSeaGreen,
1,
ButtonBorderStyle.Solid);
}
Private Sub panel1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
ControlPaint.DrawBorder(e.Graphics, Me.panel1.ClientRectangle, Color.LightSeaGreen, 1, ButtonBorderStyle.Solid, Color.LightSeaGreen, 1, ButtonBorderStyle.Solid, Color.LightSeaGreen, 1, ButtonBorderStyle.Solid, Color.LightSeaGreen, 1, ButtonBorderStyle.Solid)
End Sub
使用BorderColor属性指定边框颜色,不指定则为默认;public class PanelWithCustomBorder : Panel
{
public Color BorderColor;
public int BorderWidth = 1;
public ButtonBorderStyle BorderLineStyle = ButtonBorderStyle.Solid;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (BorderColor != null)
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
BorderColor,BorderWidth,BorderLineStyle,
BorderColor, BorderWidth, BorderLineStyle,
BorderColor, BorderWidth, BorderLineStyle,
BorderColor, BorderWidth, BorderLineStyle);
}
}
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛