title: C# Windows Form Label BackgroundImage
body: <p>I want to set a background image on a <code>Label</code>.
  I found that <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.label.backgroundimage%28v=vs.90%29.aspx" rel="nofollow">Microsoft</a> does not allow to do this. However, I want to implement by self.
  The code is in below, the problem is that how can I set the background image programmically?
  There is still no <code>BackgroundImage</code> property to set.<br /></p>
  
  <pre><code>class BackgroundImageLabel : Label
  {
      public BackgroundImageLabel()
      {
  
      }
  
      protected override void OnPaintBackground(PaintEventArgs e)
      {
          return;
      }
  
      protected override void OnPaint(PaintEventArgs e)
      {
          //is BackGroundImage null
          if (this.BackgroundImage != null)
          {
  
                  e.Graphics.DrawImage(this.BackgroundImage, new System.Drawing.Rectangle(0, 0, this.Width, this.Height),
                  this.Location.X, this.Location.Y, this.Width, this.Height,
                     System.Drawing.GraphicsUnit.Pixel);      
          }
  
          e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
          SolidBrush drawBrush = new SolidBrush(this.ForeColor);
          e.Graphics.DrawString(this.Text, this.Font, drawBrush, new System.Drawing.Rectangle(0, 0, this.Width, this.Height));
          //base.OnPaint(e);
      }
  }
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>I got another problem is that the Label is all black whatever I change the settings.
  I don't know what the reason is. Can anyone help me?</p>