This documentation is archived and is not being maintained.
How to: Use a Pen to Draw Lines
.NET Framework 2.0
To draw lines, you need aobject and a object. The Graphics object provides the method, and the Pen object stores features of the line, such as color and width.
The following example draws a line from (20, 10) to (300, 100). The first statement uses theclass constructor to create a black pen. The one argument passed to the Pen constructor is a object created with the method. The values used to create the Color object — (255, 0, 0, 0) — correspond to the alpha, red, green, and blue components of the color. These values define an opaque black pen.
Compiling the Code
The preceding example is designed for use with Windows Forms, and it requires e, which is a parameter of the event handler.