private void groupBox1_Paint(object sender, PaintEventArgs e) {
e.Graphics.Clear(groupBox1.BackColor);
SizeF fontSize = e.Graphics.MeasureString(groupBox1.Text, groupBox1.Font);
e.Graphics.DrawString(groupBox1.Text, groupBox1.Font, Brushes.MediumBlue, (groupBox1.Width - fontSize.Width) / 2, 1);
e.Graphics.DrawLine(Pens.MediumBlue, 1, 10, (groupBox1.Width - fontSize.Width) / 2, 10);
e.Graphics.DrawLine(Pens.MediumBlue, (groupBox1.Width + fontSize.Width) / 2 - 4, 10, groupBox1.Width - 2, 10);
}
c# groupbox 标题居中,并修改边框颜色
最新推荐文章于 2024-08-01 16:07:28 发布