Name

ToolboxBitmapAttribute

Synopsis

This Attribute class is something of a refugee from the System.Drawing.Design namespace. If you apply the attribute to a component and specify either the filename of a 16 × 16 bitmap, or a component type (e.g., typeof(SomeOtherComponent)), the appropriate image (either your bitmap or the image specified for the other type) will be displayed in the designer toolbox next to your component’s name.

You can also specify both, and it will fallback on the type imagery if the bitmap file doesn’t exist.

This is, of course, extremely useful; but what it is doing in this namespace is a mystery.


public class ToolboxBitmapAttribute : Attribute {

// Public Constructors

   public ToolboxBitmapAttribute(string imageFile);

   public ToolboxBitmapAttribute(Type t);

   public ToolboxBitmapAttribute(Type t, string name);

// Public Static Fields

   public static readonly ToolboxBitmapAttribute Default;  // =System.Drawing.ToolboxBitmapAttribute

                  // Public Static Methods

   public static Image GetImageFromResource(Type t, string imageName, bool large);

// Public Instance Methods

   public override bool Equals(object value);  // overrides Attribute

   public override int GetHashCode();  // overrides Attribute

   public Image GetImage(object component);

   public Image GetImage(object component, bool large);

   public Image GetImage(Type type);

   public Image GetImage(Type type, bool large);

   public Image GetImage(Type type, string imgName, bool large);

}

Hierarchy

System.Object System.Attribute ToolboxBitmapAttribute ...

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.