title: C#: Overriding OnPaint on ProgressBar not working?
body: <p>Was thinking it should be pretty easy to create a <code>ProgressBar</code> that drew some text upon itself. However, I am not quite sure what is happening here...</p>
  
  <p>I added the following two overrides:</p>
  
  <pre><code>    protected override void OnPaintBackground(PaintEventArgs pevent)
      {
          base.OnPaintBackground(pevent);
          var flags = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
          TextRenderer.DrawText(pevent.Graphics, "Hello", Font, Bounds, Color.Black, flags);
      }
  
      protected override void OnPaint(PaintEventArgs e)
      {
          base.OnPaint(e);
          var flags = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
          TextRenderer.DrawText(e.Graphics, "Hello", Font, Bounds, Color.Black, flags);
      }
  </code></pre>
  
  <p>However, I get no text, and the methods doesn't even seem to be called. What is going on here?</p>
  
  <hr>
  
  <p><strong>Update:</strong> Thanks to the two answers so far, I have gotten it to actually call the <code>OnPaint</code> by using <code>SetStyle(ControlStyles.UserPaint, true)</code>, and I have gotten it to draw the text in the right place by sending in <code>new Rectangle(0, 0, Width, Height)</code> instead of <code>Bounds</code>.</p>
  
  <p>I do get text now, but the <code>ProgressBar</code> is gone... and the point was kind of to have the text on top of the <code>ProgressBar</code>. Any idea how I can solve this?</p>