To draw lines with GDI+ you need to create a Graphics object and a Pen object. The Graphics object provides the methods that actually do the drawing, and the Pen object stores attributes, such as line color, width, and style.
To draw a line, call the DrawLine method of the Graphics object. The Pen object is passed as one of the arguments to the DrawLine method.
Below is the syntax of the DrawLine method:
| DrawLine(ByVal pen As System.Drawing.Pen, ByVal x1 As Single, ByVal y1 As Single, ByVal x2 As Single, ByVal y2 As Single) |
The following code example demonstrates how to draw a line from the point (4, 6) to the point (100, 6):