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);
}

 

WinForm GroupBox控件重绘外观

WinForm GroupBox控件重绘外观

相关文章:

  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-01-02
  • 2021-09-14
  • 2022-12-23
相关资源
相似解决方案