[Implement] 自訂 Panel 框顏色 (預設沒有框顏色的屬性)
1. 以 Panel 為例, Panel 預設沒有框顏色的屬性
//自訂panel框顏色, 預設沒有設定顏色屬性
private void panal1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawRectangle(
Pens.Gainsboro,//設定顏色
e.ClipRectangle.Left,
e.ClipRectangle.Top,
e.ClipRectangle.Width - 1,
e.ClipRectangle.Height - 1);
base.OnPaint(e);
}
2.
private void Conpoment_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(
e.Graphics, panel1.ClientRectangle,
Color.Gold, 1, ButtonBorderStyle.Solid,
Color.Green, 2, ButtonBorderStyle.Outset,
Color.Red, 3, ButtonBorderStyle.Inset,
Color.Gainsboro, 4, ButtonBorderStyle.Dotted);
}