Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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:
    static Image^ GetImageOfCustomControl(Control^ userControl)
    {
        Image^ controlImage = nullptr;
        AttributeCollection^ attrCol =
            TypeDescriptor::GetAttributes(userControl);
        ToolboxBitmapAttribute^ imageAttr = (ToolboxBitmapAttribute^)
            attrCol[ToolboxBitmapAttribute::typeid];
        if (imageAttr != nullptr)
        {
            controlImage = imageAttr->GetImage(userControl);
        }

        return controlImage;
    }

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft