title: How to draw a single line using MouseMove Event
body: <p>I'm trying to draw a single line using <code>OnMouseMove()</code> event. My Problem is that everytime I move the mouse It leaves a trail. I tried to use the refresh method, but when I stop moving the mouse the line is gone. I don't want the line to be drawn <code>OnPaint();</code>, Just want to draw it <code>OnMouseMove()</code>. </p>
  
  <p><strong>EDIT:</strong> I'm using a transparent panel(cp.ExStyle |= 0x20;), so I cant use the <code>graphics.Clear()</code> and <code>BackColor()</code></p>
  
  <p>Here's a Sample Image without the <code>Refresh()</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/ZGlcx.jpgBlockquote" alt="alt text"></p>
  
  <p>Here's my code:</p>
  
  <pre><code>private void panel1_MouseMove(object sender, MouseEventArgs e)
  {  
     Graphics g = panel1.CreateGraphics();
  
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     using (var p = new Pen(Color.Black, 3))
     {
        p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
        p.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
  
        g.DrawLine(p, st, e.Location);
     }
     Thread.Sleep(30);
     Invalidate();
     //this.Refresh();
  
     g.Dispose();
  }
  </code></pre>
  
  <p>Regards</p>