title: How to draw a selectable line?
body: <p>I want to create an application which the user is able to manipulate the line he draw. Something like Deleting the line or Selecting it. How should I do that?</p>
  
  <p>Thanks in advance</p>
  
  <hr>
  
  <p>I managed to do it using a hard coded rectangle. But I don't still have an idea how to do it using the <code>drawLine()</code> Can I use <code>drawPath</code> to do the hit test?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>private bool selectGraph = false;
  private Rectangle myrec = new Rectangle(50, 50, 100, 100);
  private Graphics g;
  
  private void panel1_Paint(object sender, PaintEventArgs e)
      {
          SolidBrush sb = new SolidBrush(Color.Blue);
          Pen p = new Pen(Color.Blue, 5);
  
          e.Graphics.DrawRectangle(p, myrec);
          e.Graphics.FillRectangle(sb, myrec);
      }
  
      private void panel1_MouseUp(object sender, MouseEventArgs e)
      {
          Point mPT = new Point(e.X, e.Y);
  
          if (e.Button == MouseButtons.Left)
          {
              if (myrec.Contains(mPT))
              {
                  selectGraph = true;
                  button1.Enabled = true;
              }
              else
              {
                  selectGraph = false;
                  button1.Enabled = false;
              }
          }
          Invalidate();
      }
  </code></pre>