title: bitmap image, gr.drawRectangle during mouse move event vb.net
body: <p>When coding this: </p>
  
  <pre><code>Sub PcbOriginalMouseMove(sender As Object, e As MouseEventArgs)
          Try
              If isSelecting = True Then
                  x1 = e.X
                  y1 = e.Y
                  Dim bm As New Bitmap(pcbOriginal.Image)
  
                  Using gr As Graphics = Graphics.FromImage(bm)
                      gr.DrawRectangle(Pens.Red, Math.Min(x0,x1), Math.Min (y0,y1), Math.Abs(x0-x1), Math.Abs(y0-y1))
                  End Using
  
                  pcbOriginal.Image = bm
              End If
          Catch ex As Exception 
          End Try 
  End Sub
  </code></pre>
  
  <p>I got a repeated rectangle (selected area when mouse move) seen in the pic:</p>
  
  <p><strong>Mouse moved quickly:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/hceyf.png" alt="drawn rectangle when moving the mouse quickly"></p>
  
  <p><strong>Mouse moved slowly:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/U7gRI.png" alt="drawn rectangle when moving the mouse slowly"></p>