SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size

How to Draw Shape (Line, Rectangle, Pie) in Visual Basic .Net?

E-mail Print PDF

This article uses Visual Basic .Net code to draw Line, Rectangle and Pie within a Form object.

Draw Two Lines
Dim g As Graphics = Me.CreateGraphics()
g.DrawLine(Pens.Black, 50, 70, 100, 250)
g.DrawLine(Pens.Black, 120, 70, 120, 250)
Draw a Rectangle (Width=100, Height=200)
Dim g As Graphics = Me.CreateGraphics
g.DrawRectangle(Pens.Blue, 220, 70, 100, 200)
Draw a Pie (Height=200, Width=100, Angle=270)
Dim g As Graphics = Me.CreateGraphics
g.DrawPie(Pens.Red, 400, 70, 100, 200, 0, 270)

Download Code Here