B
booboo_US
Guest
Hi:
I am using vb.net 2019, and I would like to draw a line, which is fairly simple. As you can see from my sample code, the drawing is done in the paint event. However, this will always draw the line no matter what. What I would like to do is for the user to input the starting coordinates of the line in two textboxes (x,y), and then click a command button. Only after the user clicks the command button, the line to be drawn in the picturebox and to stay in the picturebox.
I would appreciate a sample code. thank you.
Bob
Private Sub PictureBox3_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox3.Paint
Dim XS As Single, YS As Single
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255), 8)
pen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor
pen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor
XS = textbox1.text
YS = textbox2.text
e.Graphics.DrawLine(pen, XS, YS, 300, 175)
End Sub
Continue reading...
I am using vb.net 2019, and I would like to draw a line, which is fairly simple. As you can see from my sample code, the drawing is done in the paint event. However, this will always draw the line no matter what. What I would like to do is for the user to input the starting coordinates of the line in two textboxes (x,y), and then click a command button. Only after the user clicks the command button, the line to be drawn in the picturebox and to stay in the picturebox.
I would appreciate a sample code. thank you.
Bob
Private Sub PictureBox3_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox3.Paint
Dim XS As Single, YS As Single
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255), 8)
pen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor
pen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor
XS = textbox1.text
YS = textbox2.text
e.Graphics.DrawLine(pen, XS, YS, 300, 175)
End Sub
Continue reading...