Can't draw to a pictureBox in a loop
<p>I have a <code>List&lt;Point&gt;</code> where Point contains X and Y.</p>

<p>What i want is to loop a list like that and draw a line point to point, i do so by:</p>

<pre><code>foreach (List&lt;Point&gt; wps in map.waypoints)
{
  System.Drawing.Pen myPen;
  myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
  System.Drawing.Graphics formGraphics = this.pictureBox1.CreateGraphics();

  Point startPos = new Point(wps[0].X, wps[0].Y);

  foreach (Point p in wps)
  {
    formGraphics.DrawLine(myPen, startPos.X, startPos.Y, p.X, p.Y);
    startPos = p;
  }

  myPen.Dispose();
  formGraphics.Dispose();
}
</code></pre>

<p>BUT nothing gets drawn! I did the same with the on_click event to the pictureBox but instead if a looping some Points ive just used mouse X and Y. I have verified the lists of points that they dont contain rubish :D</p>
