Files
LL17-honghai/C-Windows-1/MyGroupBox.cs
2025-11-21 10:50:27 +08:00

35 lines
1.2 KiB
C#

using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace C_Windows_1
{
public partial class MyGroupBox : GroupBox //Component
{
public MyGroupBox()
{
InitializeComponent();
}
public MyGroupBox(IContainer container)
{
container.Add(this);
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
var vSize = e.Graphics.MeasureString(this.Text, this.Font);
e.Graphics.Clear(this.BackColor);
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), 10, 1);
e.Graphics.DrawLine(Pens.DarkSlateGray, 1, vSize.Height / 2, 8, vSize.Height / 2);
e.Graphics.DrawLine(Pens.DarkSlateGray, vSize.Width + 8, vSize.Height / 2, this.Width - 2, vSize.Height / 2);
e.Graphics.DrawLine(Pens.DarkSlateGray, 1, vSize.Height / 2, 1, this.Height - 2);
e.Graphics.DrawLine(Pens.DarkSlateGray, 1, this.Height - 2, this.Width - 2, this.Height - 2);
e.Graphics.DrawLine(Pens.DarkSlateGray, this.Width - 2, vSize.Height / 2, this.Width - 2, this.Height - 2);
}
}
}