Jaruzel.com

Draw a Line on a Picturebox Control


'Draw line on picturebox
'Put a picturebox on the form named pic

Dim bit As Bitmap = New Bitmap(pic.Width, pic.Height)
Dim g As Graphics = Graphics.FromImage(bit)
Dim myPen As Pen = New Pen(Color.Blue, 3)

g.DrawLine(myPen, 0, 0, pic.Width, pic.Height)

pic.Image = bit