How do i paint each point i click on in a different color?
<p>This is the code of mouse down where i click on the points:</p>

<pre><code>private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
   if (e.Button == MouseButtons.Left)
   {
      label1.Text = e.X.ToString();
      label2.Text = e.Y.ToString();
      label1.Visible = true;
      label2.Visible = true;
      label3.Visible = true;
      label4.Visible = true;
      // find the index that is closest to the current mouse location
      MinDist = float.MaxValue;

      for (idx = 0; idx &lt; Point_X.Count; ++idx)
      {
         float dx = Point_X[idx] - e.X;
         float dy = Point_Y[idx] - e.Y;
         float dist = (float)Math.Sqrt(dx * dx + dy * dy);

         if (dist &lt; MinDist)
         {
            MinDist = dist;
            selectedIndex = idx;
         }
      }

      if (MinDist &lt; 5)
      {
         mouseMove = true;
         OriginalX = Point_X[(int)selectedIndex];
         OriginalY = Point_Y[(int)selectedIndex];

         if (cyclicSelectedIndex.Count() == 2)
         {
            cyclicSelectedIndex[currentCyclicIndex] = (int)selectedIndex;
            currentCyclicIndex++;
            if (currentCyclicIndex &gt; 1)
            {
               currentCyclicIndex = 0;
            }
            if ((cyclicSelectedIndex[0] == cyclicSelectedIndex[1]) ||
                (cyclicSelectedIndex[0] == -1) || (cyclicSelectedIndex[1] == -1))
            {
               button2.Enabled = false;
            }
            else
            {
               button2.Enabled = true;
            }

            label13.Text = selectedIndex.ToString();
            label13.Visible = true;
            label14.Visible = true;

            listView1.Items.Add(selectedIndex.ToString()).EnsureVisible();
         }
      }
   }
}
</code></pre>

<p>And this is the paint event in the first FOR LOOP i draw the points in the second FOR LOOP i draw the lines between the points.</p>

<p>I want that if i click on one point it will be blue and if i click on second point it will be yellow. Now when i create the points they are red.</p>

<pre><code>private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
   Point connectionPointStart;
   Point connectionPointEnd;
   Graphics g = e.Graphics;
   g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
   SolidBrush brush = new SolidBrush(Color.Red);
   Pen p = new Pen(brush);
   for (int idx = 0; idx &lt; Point_X.Count; ++idx)
   {
      Point dPoint = new Point((int)Point_X[idx], (int)Point_Y[idx]);
      dPoint.X = dPoint.X - 5; // was - 2
      dPoint.Y = dPoint.Y - 5; // was - 2
      Rectangle rect = new Rectangle(dPoint, new Size(10, 10));
      g.FillEllipse(brush, rect);
   }

   for (int i = 0; i &lt; connectionStart.Count; i++)
   {
      int startIndex = connectionStart[i];
      int endIndex = connectionEnd[i];

      connectionPointStart = new Point(
         (int)Point_X[startIndex], (int)Point_Y[startIndex]);
      connectionPointEnd = new Point(
         (int)Point_X[endIndex], (int)Point_Y[endIndex]);
      p.Width = 4;
      g.DrawLine(p, connectionPointStart, connectionPointEnd);
   }
}
</code></pre>
