How to: Set the Color of a Pen (Visual C#)
This example demonstrates how to change the color of a pre-existing Pen object.
Example
myPen.Color = System.Drawing.Color.PeachPuff;
Compiling the Code
This example requires:
A Windows Forms Application project.
A Pen object named myPen.
The code must be within the scope of the Form class. The instance of the form is represented by this.
Robust Programming
You should always call Dispose on any objects that consume system resources, such as Brush and Graphics objects.
See Also
Concepts
Designing a User Interface in Visual C#