I'm writting program in VB 2010, but I have a problem. I want to draw a temporary line on PictureBox control MouseMove event. That works fine but deleting of that line doesn't work. I tried to draw the white line on the same coordinates (PictureBox's background is white), but won't work.
Here is the code:
Private Sub drawing_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles drawing.MouseMove
coordinates.Text = "X = " & e.X & "; Y = " & e.Y & ";"
If tool = 0 Then
Dim graphic As Graphics = drawing.CreateGraphics
Dim pen As New Pen(Brushes.Red, 3)
Dim eraser As New Pen(Brushes.White, 3)
If A.X = 0 And A.Y = 0 Then
Exit Sub
Else
B.X = e.X
B.Y = e.Y
With A1
.X = e.X
.Y = e.Y
End With
With B1
.X = e.X
.Y = e.Y
End With
If A.X = A1.X And B.X = B1.X Then
graphic.DrawLine(pen, A, B)
Else
graphic.DrawLine(eraser, A1, B1)
graphic.DrawLine(pen, A, B)
End If
End If
End If
End Sub