using System.Drawing; using System.Windows.Forms; namespace UAS_LabelMachine.CustomControl.GroupBoxWithBorder { public partial class GroupBoxWithBorder : GroupBox { public GroupBoxWithBorder() { InitializeComponent(); this.Paint += this.groupBox1_Paint; } private void groupBox1_Paint(object sender, PaintEventArgs e) { e.Graphics.Clear(this.BackColor); e.Graphics.DrawString(this.Text, this.Font, Brushes.Black, 10, 1); Pen LineColor = Pens.Gray; e.Graphics.DrawLine(LineColor, 1, 7, 8, 7); e.Graphics.DrawLine(LineColor, e.Graphics.MeasureString(this.Text, this.Font).Width + 8, 7, this.Width - 2, 7); e.Graphics.DrawLine(LineColor, 1, 7, 1, this.Height - 2); e.Graphics.DrawLine(LineColor, 1, this.Height - 2, this.Width - 2, this.Height - 2); e.Graphics.DrawLine(LineColor, this.Width - 2, 7, this.Width - 2, this.Height - 2); } } }