GroupBoxWithBorder.cs 1022 B

1234567891011121314151617181920212223242526
  1. using System.Drawing;
  2. using System.Windows.Forms;
  3. namespace UAS_LabelMachine.CustomControl.GroupBoxWithBorder
  4. {
  5. public partial class GroupBoxWithBorder : GroupBox
  6. {
  7. public GroupBoxWithBorder()
  8. {
  9. InitializeComponent();
  10. this.Paint += this.groupBox1_Paint;
  11. }
  12. private void groupBox1_Paint(object sender, PaintEventArgs e)
  13. {
  14. e.Graphics.Clear(this.BackColor);
  15. e.Graphics.DrawString(this.Text, this.Font, Brushes.Black, 10, 1);
  16. Pen LineColor = Pens.Gray;
  17. e.Graphics.DrawLine(LineColor, 1, 7, 8, 7);
  18. e.Graphics.DrawLine(LineColor, e.Graphics.MeasureString(this.Text, this.Font).Width + 8, 7, this.Width - 2, 7);
  19. e.Graphics.DrawLine(LineColor, 1, 7, 1, this.Height - 2);
  20. e.Graphics.DrawLine(LineColor, 1, this.Height - 2, this.Width - 2, this.Height - 2);
  21. e.Graphics.DrawLine(LineColor, this.Width - 2, 7, this.Width - 2, this.Height - 2);
  22. }
  23. }
  24. }