Export (0) Print
Expand All

ToolboxBitmapAttribute.GetImage Method (Object)

Gets the small Image associated with this ToolboxBitmapAttribute object.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public Image GetImage(
	Object component
)

Parameters

component
Type: System.Object
If this ToolboxBitmapAttribute object does not already have a small image, this method searches for a bitmap resource in the assembly that defines the type of the object specified by the component parameter. For example, if you pass an object of type ControlA to the component parameter, then this method searches the assembly that defines ControlA.

Return Value

Type: System.Drawing.Image
The small Image associated with this ToolboxBitmapAttribute object.

This method searches for a resource named namespace.classname.bmp, where namespace is the namespace containing the definition of the type of the object specified by the component parameter. For example, suppose you pass an object of type ControlA to the component parameter. If ControlA is in NamespaceA in AssemblyA.dll, then this method searches AssemblyA.dll for a resource named NamespaceA.ControlA.bmp.

The following example demonstrates how to use the GetImage method.


private Image GetImageOfCustomControl(Control userControl)
{
    Image controlImage = null;
    AttributeCollection attrCol = 
            TypeDescriptor.GetAttributes(userControl);
    ToolboxBitmapAttribute imageAttr = (ToolboxBitmapAttribute)
        attrCol[typeof(ToolboxBitmapAttribute)];
    if (imageAttr != null)
    {
        controlImage = imageAttr.GetImage(userControl);
    }

    return controlImage;
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft