Name

SolidBrush

Synopsis

This class is the day-to-day workhorse of the GDI+ world. If you cannot find the brush you need in SystemBrushes or Brushes, and you don’t need the fancy effects of the options found in System.Drawing.Drawing2D, you will be using instances of this class (derived from Brush) to fill solid areas of color in your shapes, including the font stroke color when painting text. You can construct an instance from a Color value, and can also set and retrieve the Color through a property of that name over the lifetime of the object.

As with most GDI+ resources, this implements IDisposable and must therefore have its lifetime managed carefully, calling Dispose() when you are finished with it. As with other examples, the C# using idiom is useful here.


public sealed class SolidBrush : Brush : System.Drawing.Internal.ISystemColorTracker {

// Public Constructors

   public SolidBrush(Color color);

// Public Instance Properties

   public Color Color{set; get; }

// Public Instance Methods

   public override object Clone();  // overrides Brush

                  // Protected Instance Methods

   protected override void Dispose(bool disposing);  // overrides Brush

}

Hierarchy

System.Object System.MarshalByRefObject Brush(System.ICloneabl, System.IDisposable) SolidBrush(System.Drawing.Internal.ISystemColorTracker)

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.