In one form of my VB.NET Windows application, I have a picturebox. I need to draw a line (using known coordinates) on picturebox when the form is loading. Following is the code I wrote in my Form_Load event.
Private Sub frm_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
PictureBox1.Refresh()
Dim g As Graphics = CType( PictureBox1, PictureBox).CreateGraphics
Dim myPen As New Pen(Color.Red)
myPen.Width = 2
g.DrawLine(myPen, 0, 0, 100, 100)
myPen.Dispose()
g.Dispose()
End Sub
But its not displaying the Line when the Form is loading. I cannot figure out why.
Thank you
Private Sub frm_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
PictureBox1.Refresh()
Dim g As Graphics = CType( PictureBox1, PictureBox).CreateGraphics
Dim myPen As New Pen(Color.Red)
myPen.Width = 2
g.DrawLine(myPen, 0, 0, 100, 100)
myPen.Dispose()
g.Dispose()
End Sub
But its not displaying the Line when the Form is loading. I cannot figure out why.
Thank you