https://www.cnblogs.com/CUIT-DX037/p/7246231.html
public partial class TestForm : Form
{
public TestForm()
{
InitializeComponent();
this.groupBox1.Paint += groupBox_Paint;
this.groupBox2.Paint += groupBox_Paint;
}
void groupBox_Paint(object sender, PaintEventArgs e)
{
GroupBox gBox = (GroupBox)sender;
e.Graphics.Clear(gBox.BackColor);
e.Graphics.DrawString(gBox.Text, gBox.Font, Brushes.Red, 10, 1);
var vSize = e.Graphics.MeasureString(gBox.Text, gBox.Font);
e.Graphics.DrawLine(Pens.Red, 1, vSize.Height / 2, 8, vSize.Height / 2);
e.Graphics.DrawLine(Pens.Red, vSize.Width + 8, vSize.Height / 2, gBox.Width - 2, vSize.Height / 2);
e.Graphics.DrawLine(Pens.Red, 1, vSize.Height / 2, 1, gBox.Height - 2);
e.Graphics.DrawLine(Pens.Red, 1, gBox.Height - 2, gBox.Width - 2, gBox.Height - 2);
e.Graphics.DrawLine(Pens.Red, gBox.Width - 2, vSize.Height / 2, gBox.Width - 2, gBox.Height - 2);
}
private void TestForm_Load(object sender, EventArgs e)
{
}
}
[本日志由 tiancao1001 于 2021-01-09 06:11 PM 编辑]
|  | 
暂时没有评论
| 发表评论 - 不要忘了输入验证码哦! | 
 
 
 
				 用户登陆
 用户登陆 站点日历
 站点日历 站点统计
 站点统计 最新评论
 最新评论 
 
 C#窗体控件GroupBox修改边框色   [ 日期:2021-01-09 ]   [ 来自:
 C#窗体控件GroupBox修改边框色   [ 日期:2021-01-09 ]   [ 来自: