VB Code:
Dim OldLineStart As Point
Dim OldLineEnd As Point
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Dim R As Rectangle = PictureBox1.ClientRectangle
R.Offset(PictureBox1.PointToScreen(PictureBox1.ClientRectangle.Location))
Cursor.Clip = R
OldLineStart = PictureBox1.PointToScreen(New Point(e.X, e.Y))
OldLineEnd = OldLineStart
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Cursor.Clip = Nothing
PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button = MouseButtons.Left Then
ControlPaint.DrawReversibleLine(OldLineStart, OldLineEnd, PictureBox1.BackColor)
OldLineEnd = PictureBox1.PointToScreen(New Point(e.X, e.Y))
ControlPaint.DrawReversibleLine(OldLineStart, OldLineEnd, PictureBox1.BackColor)
End If
End Sub