title: Drawing circles on top of a form
body: <p>I've got a WinForms app and I want to programatically draw circles on top of certain areas. I'm running into a couple problems and any insight would be appreciated!</p>
  
  <p>1) I've got code for drawing and clearing the circles (see below), but the circles are being drawn behind all my controls. I want them to be drawn as "top-most" in every case. How do I do this?</p>
  
  <p>2) When my app starts up, I'll have some circles that need to be drawn right away. I tried drawing them on the Form Load event to no avail. But as to here (<a href="https://stackoverflow.com/questions/2684065/form-graphics-not-set-when-form-loads">Form graphics not set when form loads</a>) I'm now drawing it on the Paint event. While this works reasonably well (with a bool to make sure it only does it the first time), It seems to have problems with the <code>this.Invalidate();</code> (as no circles are getting drawn). Is there a better way? Here's my code (<code>parseText</code> runs on a the index change of a comboBox):</p>
  
  <pre><code>private void parseText()
  {
      this.Invalidate();
      List&lt;string&gt; lines = new List&lt;string&gt;(richTextBoxRaw.Text.Split(new string[] { Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries));
  
      foreach (string s in lines)
      {
          switch (s)
          {
              case "&lt;draw1&gt;":
                  drawCircle(107, 26, 25);
                  break;
              default:
                  break;
          }
      }
  }
  
  private void drawCircle(int x, int y, int transparency)
  {
      if (transparency &lt; 0)
          transparency = 0;
      else if (transparency &gt; 255)
          transparency = 255;
  
      SolidBrush brush = new SolidBrush(Color.FromArgb(transparency, 255,0,0));
      Graphics graphics = this.CreateGraphics();
  
      graphics.FillEllipse(brush, new Rectangle(x, y, 25, 25));
      brush.Dispose();
      graphics.Dispose();
  }
  
  private void Form1_Paint(object sender, PaintEventArgs e)
  {
      if (starting)
          parseText();
  
      starting = false;
  }
  </code></pre>