winform c# groupBox 的边框颜色
|
private void groupBox1_Paint(object sender, PaintEventArgs e)
{ e.Graphics.Clear(groupBox1.BackColor); e.Graphics.DrawString(groupBox1.Text, groupBox1.Font, Brushes.Red, 10, 1); e.Graphics.DrawLine(Pens.Red, 1, 7, 8, 7); e.Graphics.DrawLine(Pens.Red, e.Graphics.MeasureString(groupBox1.Text, groupBox1.Font).Width + 8, 7, groupBox1.Width - 2, 7); e.Graphics.DrawLine(Pens.Red, 1, 7, 1, groupBox1.Height - 2); e.Graphics.DrawLine(Pens.Red, 1, groupBox1.Height - 2, groupBox1.Width - 2, groupBox1.Height - 2); e.Graphics.DrawLine(Pens.Red, groupBox1.Width - 2, 7, groupBox1.Width - 2, groupBox1.Height - 2); } |
本文介绍了一种使用C#在WinForms应用程序中自定义GroupBox边框颜色的方法。通过重写Paint事件,可以实现GroupBox边框的颜色自定义,示例代码展示了如何将边框设置为红色。
1142

被折叠的 条评论
为什么被折叠?



