Filling a Shape with a Solid Color

To fill a shape with a solid color, create a SolidBrush object, and then pass that SolidBrush object as an argument to one of the fill methods of the Graphics class. The following example shows how to fill an ellipse with the color red:

Dim solidBrush As New SolidBrush( _
   Color.FromArgb(255, 255, 0, 0))
e.Graphics.FillEllipse(solidBrush, 0, 0, 100, 60)
[C#]
SolidBrush solidBrush = new SolidBrush(
   Color.FromArgb(255, 255, 0, 0));
e.Graphics.FillEllipse(solidBrush, 0, 0, 100, 60);

In the preceding code, the SolidBrush constructor takes a Color object as its only argument. The values used by the Color.FromArgb method represent the alpha, red, green, and blue components of the color. Each of these values must be in the range 0 through 255. The first 255 indicates that the color is fully opaque, and the second 255 indicates that the red component is at full intensity. The two zeros indicate that the green and blue components both have an intensity of 0.

The four numbers (0, 0, 100, 60) passed to the FillEllipse method specify the location and size of the bounding rectangle for the ellipse. The rectangle has an upper-left corner of (0, 0), a width of 100, and a height of 60.