Pen Constructor (Brush, Single)
.NET Framework 4.6 and 4.5
Initializes a new instance of the Pen class with the specified Brush and Width.
The Brush is set to the color specified in the brush parameter, the Width property is set to the value specified in the width parameter, and the units are set to World.
Note that the brush parameter also specifies the Color property of this Pen.
A width of 0 will result in the Pen drawing as if the width were 1.
The following code example creates a Pen and demonstrates the effects of setting the StartCap and EndCap properties on a Pen.
This example is designed to be used with Windows Forms. Paste the code into a form and call the ShowStartAndEndCaps method when handling the form's Paint event, passing e as PaintEventArgs.
private void Button3_Click(System.Object sender, System.EventArgs e)
Graphics buttonGraphics = Button3.CreateGraphics();
Pen myPen = new Pen(Color.ForestGreen, 4.0F);
myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
Rectangle theRectangle = Button3.ClientRectangle;
Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
.NET Framework Client Profile
Supported in: 4, 3.5 SP1