title: Draw a border around GroupBox C#
body: <p>The other solutions on this site haven't worked for me so I'm trying to figure out what I'm doing wrong:</p>
  
  <p>This is WinForm App</p>
  
  <pre><code>private void dk_buff_box_Paint(object sender, PaintEventArgs e)
      {
          Console.WriteLine("INSIDE!!");
          ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);
          GroupBox box = sender as GroupBox;
          DrawGroupBox(box, e.Graphics, Color.Red, Color.Black);
      }
      private void DrawGroupBox(GroupBox box, Graphics g, Color textColor, Color borderColor)
      {
          if (box != null)
          {
              Brush textBrush = new SolidBrush(textColor);
              Brush borderBrush = new SolidBrush(borderColor);
              Pen borderPen = new Pen(borderBrush);
              SizeF strSize = g.MeasureString(box.Text, box.Font);
              Rectangle rect = new Rectangle(box.ClientRectangle.X,
                                             box.ClientRectangle.Y + (int)(strSize.Height / 2),
                                             box.ClientRectangle.Width - 1,
                                             box.ClientRectangle.Height - (int)(strSize.Height / 2) - 1);
  
              // Clear text and border
              g.Clear(this.BackColor);
  
              // Draw text
              g.DrawString(box.Text, box.Font, textBrush, box.Padding.Left, 0);
  
              // Drawing Border
              //Left
              g.DrawLine(borderPen, rect.Location, new Point(rect.X, rect.Y + rect.Height));
              //Right
              g.DrawLine(borderPen, new Point(rect.X + rect.Width, rect.Y), new Point(rect.X + rect.Width, rect.Y + rect.Height));
              //Bottom
              g.DrawLine(borderPen, new Point(rect.X, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));
              //Top1
              g.DrawLine(borderPen, new Point(rect.X, rect.Y), new Point(rect.X + box.Padding.Left, rect.Y));
              //Top2
              g.DrawLine(borderPen, new Point(rect.X + box.Padding.Left + (int)(strSize.Width), rect.Y), new Point(rect.X + rect.Width, rect.Y));
          }
      }
  </code></pre>
  
  <p>This code never fires the "INSIDE!!" to my console output and the border around the groupbox (called dk_buff_box) is always grey and very light. (i'm presuming that is default??)</p>
  
  <p>What do I need to do to get this border to change color?
  I have a couple .cs files that are working together (controls)  The main .cs file is form1.cs.  The code above is on a seperate .cs file called darkknightinfo.cs</p>
  
  <p>Should the code be on the main form? or should it be on the .cs file that has the actual groupbox on it?</p>
  
  <p>what do I need to do to get the _Paint() to properly activate and run the code to change the groupbox border color?</p>