ToolboxBitmapAttribute.GetImage 方法

定义

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

重载

名称 说明
GetImage(Object)

获取与此Image对象关联的小型ToolboxBitmapAttribute

GetImage(Type)

获取与此Image对象关联的小型ToolboxBitmapAttribute

GetImage(Object, Boolean)

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

GetImage(Type, Boolean)

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

GetImage(Type, String, Boolean)

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

GetImage(Object)

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

获取与此Image对象关联的小型ToolboxBitmapAttribute

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

参数

component
Object

如果此 ToolboxBitmapAttribute 对象还没有小图像,此方法将在程序集中搜索一个位图资源,该资源定义组件参数指定的对象类型。 例如,如果将 Type ControlA 的对象传递给组件参数,则此方法将搜索定义 ControlA 的程序集。

返回

与此Image对象关联的小型ToolboxBitmapAttribute

示例

以下示例演示如何使用 GetImage 该方法。

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

注解

此方法搜索名为 namespace.classname.bmp的资源,其中命名空间是包含参数所指定 component 对象的类型的定义的命名空间。 例如,假设将 ControlA 类型的对象传递给 component 参数。 如果 ControlA 位于 AssemblyA.dll中的 NamespaceA 中,此方法将搜索 AssemblyA.dll 名为 NamespaceA.ControlA.bmp的资源。

适用于

GetImage(Type)

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

获取与此Image对象关联的小型ToolboxBitmapAttribute

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

参数

type
Type

如果此 ToolboxBitmapAttribute 对象还没有小图像,此方法将在程序集中搜索一个位图资源,该资源定义类型参数指定的类型。 例如,如果将 typeof(ControlA)传递给类型参数,则此方法将搜索定义 ControlA 的程序集。

返回

与此Image对象关联的小型ToolboxBitmapAttribute

注解

此方法搜索名为 namespace.classname.bmp的资源,其中命名空间是包含参数指定的 type 类型的定义的命名空间。 例如,假设将 typeof(ControlA)传递给 type 参数。 如果 ControlA 位于 AssemblyA.dll中的 NamespaceA 中,此方法将搜索 AssemblyA.dll 名为 NamespaceA.ControlA.bmp的资源。

适用于

GetImage(Object, Boolean)

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

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

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

参数

component
Object

如果此 ToolboxBitmapAttribute 对象还没有小图像,此方法将在程序集中搜索一个位图资源,该资源定义组件参数指定的对象类型。 例如,如果将 Type ControlA 的对象传递给组件参数,则此方法将搜索定义 ControlA 的程序集。

large
Boolean

指定此方法是返回大型图像(true)还是小图像(false)。 小图像为 16 到 16,大图像为 32 到 32。

返回

与此ImageToolboxBitmapAttribute对象关联的对象。

注解

此方法搜索名为 namespace.classname.bmp的资源,其中命名空间是包含参数所指定 component 对象的类型的定义的命名空间。 例如,假设将 ControlA 类型的对象传递给 component 参数。 如果 ControlA 位于 AssemblyA.dll中的 NamespaceA 中,此方法将搜索 AssemblyA.dll 名为 NamespaceA.ControlA.bmp的资源。

如果此 ToolboxBitmapAttribute 对象还没有大型图像,则此方法通过缩放小图像来创建大型图像。

适用于

GetImage(Type, Boolean)

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

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

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

参数

type
Type

如果此 ToolboxBitmapAttribute 对象还没有小图像,此方法将在程序集中搜索一个位图资源,该资源定义组件类型指定的类型。 例如,如果将 typeof(ControlA)传递给类型参数,则此方法将搜索定义 ControlA 的程序集。

large
Boolean

指定此方法是返回大型图像(true)还是小图像(false)。 小图像为 16 到 16,大图像为 32 到 32。

返回

与此Image对象关联的对象ToolboxBitmapAttribute

注解

此方法搜索名为 namespace.classname.bmp的资源,其中命名空间是包含参数指定的 type 类型的定义的命名空间。 例如,假设将 typeof(ControlA)传递给 type 参数。 如果 ControlA 位于 AssemblyA.dll中的 NamespaceA 中,此方法将搜索 AssemblyA.dll 名为 NamespaceA.ControlA.bmp的资源。

如果此 ToolboxBitmapAttribute 对象还没有大型图像,则此方法通过缩放小图像来创建大型图像。

适用于

GetImage(Type, String, Boolean)

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

获取与此Image对象关联的小型或大型ToolboxBitmapAttribute

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

参数

type
Type

如果此 ToolboxBitmapAttribute 对象还没有小图像,此方法将在程序集中搜索嵌入的位图资源,该资源定义组件类型指定的类型。 例如,如果将 typeof(ControlA)传递给类型参数,则此方法将搜索定义 ControlA 的程序集。

imgName
String

嵌入位图资源的名称。

large
Boolean

指定此方法是返回大型图像(true)还是小图像(false)。 小图像为 16 到 16,大图像为 32 到 32。

返回

与此Image对象关联的对象ToolboxBitmapAttribute

注解

此方法搜索名为 namespace.imgName 的资源,其中命名空间是包含参数所指定 type 类型的定义的命名空间。 例如,假设将 typeof(ControlA)传递给 type 参数,并将“MyBitmap.bmp”传递给 imgName 参数。 如果 ControlA 位于 AssemblyA.dll中的 NamespaceA 中,此方法将搜索 AssemblyA.dll 名为 NamespaceA.MyBitmap.bmp的资源。

如果此 ToolboxBitmapAttribute 对象还没有大型图像,则此方法通过缩放小图像来创建大型图像。

适用于