WinForm GroupBox控件重绘外观
private void groupBoxFun_Paint(PaintEventArgs e, GroupBox groupBox)
{
e.Graphics.Clear(groupBox.BackColor);
e.Graphics.DrawString(groupBox.Text, groupBox.Font, Brushes.Blue, 10, 1);
e.Graphics.DrawLine(Pens.CornflowerBlue, 1, 7, 8, 7);
e.Graphics.DrawLine(Pens.CornflowerBlue, e.Graphics.MeasureString(groupBox.Text, groupBox.Font).Width + 8 + 2, 7, groupBox.Width - 2, 7);
e.Graphics.DrawLine(Pens.CornflowerBlue, 1, 7, 1, groupBox.Height - 2);
e.Graphics.DrawLine(Pens.CornflowerBlue, 1, groupBox.Height - 2, groupBox.Width - 2, groupBox.Height - 2);
e.Graphics.DrawLine(Pens.CornflowerBlue, groupBox.Width - 2, 7, groupBox.Width - 2, groupBox.Height - 2);
}
GroupBox控件的Paint事件中调用:
private void groupBox1_Paint(object sender, PaintEventArgs e)
{
groupBoxFun_Paint(e, groupBox1);
}