Editare

Partajați prin


ToolboxBitmapAttribute.GetImage Method

Definition

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

Overloads

GetImage(Object)

Gets the small Image associated with this ToolboxBitmapAttribute object.

GetImage(Type)

Gets the small Image associated with this ToolboxBitmapAttribute object.

GetImage(Object, Boolean)

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

GetImage(Type, Boolean)

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

GetImage(Type, String, Boolean)

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

GetImage(Object)

Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs

Gets the small Image associated with this ToolboxBitmapAttribute object.

public:
 System::Drawing::Image ^ GetImage(System::Object ^ component);
public System.Drawing.Image? GetImage (object? component);
public System.Drawing.Image GetImage (object component);
member this.GetImage : obj -> System.Drawing.Image
Public Function GetImage (component As Object) As Image

Parameters

component
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.

Returns

The small Image associated with this ToolboxBitmapAttribute object.

Examples

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;
    }
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;
}
Private Function GetImageOfCustomControl(ByVal userControl As Control) As Image 
    Dim controlImage As Image = Nothing
    Dim attrCol As AttributeCollection = TypeDescriptor.GetAttributes(userControl)
    Dim imageAttr As ToolboxBitmapAttribute = _
        CType(attrCol(GetType(ToolboxBitmapAttribute)), ToolboxBitmapAttribute)
    If (imageAttr IsNot Nothing) Then
        controlImage = imageAttr.GetImage(userControl)
    End If
    
    Return controlImage

End Function

Remarks

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.

Applies to

GetImage(Type)

Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs

Gets the small Image associated with this ToolboxBitmapAttribute object.

public:
 System::Drawing::Image ^ GetImage(Type ^ type);
public System.Drawing.Image? GetImage (Type type);
public System.Drawing.Image GetImage (Type type);
member this.GetImage : Type -> System.Drawing.Image
Public Function GetImage (type As Type) As Image

Parameters

type
Type

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 specified by the type parameter. For example, if you pass typeof(ControlA) to the type parameter, then this method searches the assembly that defines ControlA.

Returns

The small Image associated with this ToolboxBitmapAttribute object.

Remarks

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

Applies to

GetImage(Object, Boolean)

Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

public:
 System::Drawing::Image ^ GetImage(System::Object ^ component, bool large);
public System.Drawing.Image? GetImage (object? component, bool large);
public System.Drawing.Image GetImage (object component, bool large);
member this.GetImage : obj * bool -> System.Drawing.Image
Public Function GetImage (component As Object, large As Boolean) As Image

Parameters

component
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.

large
Boolean

Specifies whether this method returns a large image (true) or a small image (false). The small image is 16 by 16, and the large image is 32 by 32.

Returns

An Image object associated with this ToolboxBitmapAttribute object.

Remarks

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.

If this ToolboxBitmapAttribute object does not already have a large image, this method creates a large image by scaling the small image.

Applies to

GetImage(Type, Boolean)

Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

public:
 System::Drawing::Image ^ GetImage(Type ^ type, bool large);
public System.Drawing.Image? GetImage (Type type, bool large);
public System.Drawing.Image GetImage (Type type, bool large);
member this.GetImage : Type * bool -> System.Drawing.Image
Public Function GetImage (type As Type, large As Boolean) As Image

Parameters

type
Type

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 specified by the component type. For example, if you pass typeof(ControlA) to the type parameter, then this method searches the assembly that defines ControlA.

large
Boolean

Specifies whether this method returns a large image (true) or a small image (false). The small image is 16 by 16, and the large image is 32 by 32.

Returns

An Image associated with this ToolboxBitmapAttribute object.

Remarks

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

If this ToolboxBitmapAttribute object does not already have a large image, this method creates a large image by scaling the small image.

Applies to

GetImage(Type, String, Boolean)

Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs
Source:
ToolboxBitmapAttribute.cs

Gets the small or large Image associated with this ToolboxBitmapAttribute object.

public:
 System::Drawing::Image ^ GetImage(Type ^ type, System::String ^ imgName, bool large);
public System.Drawing.Image? GetImage (Type type, string? imgName, bool large);
public System.Drawing.Image GetImage (Type type, string imgName, bool large);
member this.GetImage : Type * string * bool -> System.Drawing.Image
Public Function GetImage (type As Type, imgName As String, large As Boolean) As Image

Parameters

type
Type

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

imgName
String

The name of the embedded bitmap resource.

large
Boolean

Specifies whether this method returns a large image (true) or a small image (false). The small image is 16 by 16, and the large image is 32 by 32.

Returns

An Image associated with this ToolboxBitmapAttribute object.

Remarks

This method searches for a resource named namespace.imgName, where namespace is the namespace containing the definition of the type specified by the type parameter. For example, suppose you pass typeof(ControlA) to the type parameter and that you passed "MyBitmap.bmp" to the imgName parameter. If ControlA is in NamespaceA in AssemblyA.dll, then this method searches AssemblyA.dll for a resource named NamespaceA.MyBitmap.bmp.

If this ToolboxBitmapAttribute object does not already have a large image, this method creates a large image by scaling the small image.

Applies to