title: C# Winforms - Flat Button Style - Transparent Border
body: <p>I've recently created a new control - a flat button - so no border, transparent background, no mouse down color, etc. The problem is, once the app is compiled and running, a black border is around the transparent background. I am going to attach two images - the first is how it looks on the app while running and second is how it looks on the design screen (how i want it to look). I'd appreciate any help getting this border to go away. Thank you!</p>
  
  <pre><code>public FlatButton() : base()
  {
      FlatStyle = System.Windows.Forms.FlatStyle.Flat;
      FlatAppearance.BorderSize = 0;
      FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);
      BackColor = Color.FromArgb(0, 255, 255, 255);    
  }
  
  protected override void OnPaint(PaintEventArgs e)
  {
      base.OnPaint(e);
      Pen pen = new Pen(FlatAppearance.BorderColor, 0);
      Rectangle rectangle = new Rectangle(0, 0, Size.Width - 2, Size.Height - 2);
      e.Graphics.DrawRectangle(pen, rectangle);   
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rCO2H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCO2H.png" alt="In App"></a></p>
  
  <p><a href="https://i.stack.imgur.com/3S202.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3S202.png" alt="In designer"></a></p>