Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
Static last As Point
If e.Button = Windows.Forms.MouseButtons.Left Then
PictureBox2.CreateGraphics.DrawLine(Pens.White, last.X, last.Y, e.X, e.Y)
last = e.Location
It would be good to have a bit more details of your code, especially how and in what class you store the X and Y coordinate. By the way you draw a line between 2 points so you would need two sets of X and Y coordinate boxes on your form. After that it is as easy as what you found on the internet using the DrawLine method (https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawline(v=vs.110).aspx), you just needs to fire it from the Click event of your "draw" button.
Hi again Ahmed Here is a simple sample of a form that would draw a line when button is clicked. Of course it would need more bootstrapping to make sure user only enter integer value for the number of pixels and in its basic form, (0,0) is the top left of the panel but it can easily be converted for a bottom left approach...
Class Form1 Private Sub cmdDraw_Click(sender As Object, e As EventArgs) Handles cmdDraw.Click Dim x1 As Integer = Integer.Parse(txtX1.Text) Dim y1 As Integer = Integer.Parse(txtY1.Text) Dim x2 As Integer = Integer.Parse(txtX2.Text) Dim y2 As Integer = Integer.Parse(txtY2.Text) pnlMap.CreateGraphics.DrawLine(New Pen(Color.Black), x1, y1, x2, y2) End Sub End Class