Draw line in vb.net

  • Thread starter Thread starter booboo_US
  • Start date Start date
B

booboo_US

Guest
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255), 8)
pen.StartCap = System.Drawing.Drawing2D.LineCap.Custom
pen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor
e.Graphics.DrawLine(pen, e.x, e.y, e.x + 10, e.y + 15)
end sub



Hi Everyone:

I am using VB.Net 2019. I have a picturebox with its image set so some picture. I need to draw a line on top of the image, at the location when the user clicks the mouse (x,y) to (x+10,y+15). However, I am not exactly how to do this. I have read that I have to place the actually drawing of the line inside the Paint event, but in there, there is no x or y of the mouse. and if I try to put it draw inside the click even, I get an error as the e.Drawing does not exist in the click event. Here is my code. Of course the last line is full of errors. Thanks;

Continue reading...
 
Back
Top