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)

來源:
ToolboxBitmapAttribute.cs
來源:
ToolboxBitmapAttribute.cs
來源:
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 物件尚未有小型影像,這個方法會在定義元件參數所指定物件型別的組件中搜尋點陣圖資源。 例如,如果您傳遞 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 的資源,其中namespace是包含參數所 component 指定物件類型定義的命名空間。 例如,假設您將ControlA類型的對象傳遞至 component 參數。 如果 ControlA 位於 AssemblyA.dll 中的 NamespaceA,則此方法會搜尋 AssemblyA.dll 名為 NamespaceA.ControlA.bmp 的資源。

適用於

GetImage(Type)

來源:
ToolboxBitmapAttribute.cs
來源:
ToolboxBitmapAttribute.cs
來源:
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 的資源,其中namespace是包含參數所 type 指定類型定義的命名空間。 例如,假設您將 typeof (ControlA) type 傳遞給 參數。 如果 ControlA 位於 AssemblyA.dll 中的 NamespaceA,則此方法會搜尋 AssemblyA.dll 名為 NamespaceA.ControlA.bmp 的資源。

適用於

GetImage(Object, Boolean)

來源:
ToolboxBitmapAttribute.cs
來源:
ToolboxBitmapAttribute.cs
來源:
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 物件尚未有小型影像,這個方法會在定義元件參數所指定物件型別的組件中搜尋點陣圖資源。 例如,如果您傳遞 ControlA 型別的物件至元件參數,那麼這個方法會在定義 ControlA 的組件中搜尋。

large
Boolean

指定這個方法是否傳回大型影像 (true) 或小型影像 (false)。 小型影像為 16 x 16,而大型影像為 32 x 32。

傳回

與這個 Image 物件關聯的 ToolboxBitmapAttribute 物件。

備註

這個方法會搜尋名為 namespace.classname.bmp 的資源,其中namespace是包含參數所 component 指定物件類型定義的命名空間。 例如,假設您將ControlA類型的對象傳遞至 component 參數。 如果 ControlA 位於 AssemblyA.dll 中的 NamespaceA,則此方法會搜尋 AssemblyA.dll 名為 NamespaceA.ControlA.bmp 的資源。

如果這個 ToolboxBitmapAttribute 物件還沒有大型影像,這個方法會藉由調整小型影像來建立大型影像。

適用於

GetImage(Type, Boolean)

來源:
ToolboxBitmapAttribute.cs
來源:
ToolboxBitmapAttribute.cs
來源:
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 x 16,而大型影像為 32 x 32。

傳回

與這個 Image 物件關聯的 ToolboxBitmapAttribute

備註

這個方法會搜尋名為 namespace.classname.bmp 的資源,其中namespace是包含參數所 type 指定類型定義的命名空間。 例如,假設您將 typeof (ControlA) 傳遞至 type 參數。 如果 ControlA 位於 AssemblyA.dll 中的 NamespaceA,則此方法會搜尋 AssemblyA.dll 名為 NamespaceA.ControlA.bmp 的資源。

如果這個 ToolboxBitmapAttribute 物件還沒有大型影像,這個方法會藉由調整小型影像來建立大型影像。

適用於

GetImage(Type, String, Boolean)

來源:
ToolboxBitmapAttribute.cs
來源:
ToolboxBitmapAttribute.cs
來源:
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 x 16,而大型影像為 32 x 32。

傳回

與這個 Image 物件關聯的 ToolboxBitmapAttribute

備註

這個方法會搜尋名為 namespace.imgName 的資源,其中 namespace 是包含 參數所 type 指定類型定義的命名空間。 例如,假設您將 typeof (ControlA) 傳遞至 type 參數,並將 “MyBitmap.bmp” 傳遞給 imgName 參數。 如果 ControlA 位於 AssemblyA.dll 中的 NamespaceA,則此方法會搜尋 AssemblyA.dll 名為 NamespaceA.MyBitmap.bmp 的資源。

如果這個 ToolboxBitmapAttribute 物件還沒有大型影像,這個方法會藉由調整小型影像來建立大型影像。

適用於