Tag Archives: pen

Draw a Line on a WindowsForm using VB.NET and Higher

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Shows how to use Visual Basic.NET and GDI+ to draw a line on the form.

        'Draws a line on the form in .NET
        Dim bit As Bitmap = New Bitmap(Me.Width, Me.Height)

        Dim g As Graphics = Graphics.FromImage(bit)

        Dim myPen As Pen = New Pen(Color.Blue, 3)

        Me.CreateGraphics.DrawLine(myPen, 0, 0, Me.Width, Me.Height)