1.
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panal1_Paint);
//自訂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.
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(Conpoment_Paint);
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
);
}
留言列表