ToolboxBitmapAttribute Clase

Definición

Le permite especificar un icono para representar un control en un contenedor, como el Diseñador de formularios de Microsoft Visual Studio.

public ref class ToolboxBitmapAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public class ToolboxBitmapAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type ToolboxBitmapAttribute = class
    inherit Attribute
Public Class ToolboxBitmapAttribute
Inherits Attribute
Herencia
ToolboxBitmapAttribute
Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la ToolboxBitmapAttribute clase para establecer stop.bmp como el icono del cuadro de herramientas para .StopSignControl En este ejemplo se supone que existe un mapa de bits de 16 por 16 píxeles denominado stop.bmp en c:\.

[ToolboxBitmap("c:\\stop.bmp")]
public ref class StopSignControl:
    public System::Windows::Forms::UserControl
{
private:
    Label^ label1;
private:
    Button^ button1;

public:
    StopSignControl() : UserControl()
    {
        this->label1 = gcnew System::Windows::Forms::Label();
        this->button1 = gcnew System::Windows::Forms::Button();

        this->label1->Font = gcnew System::Drawing::Font(
            "Microsoft Sans Serif", 12.0F,
            System::Drawing::FontStyle::Regular,
            System::Drawing::GraphicsUnit::Point, ((Byte) 0));

        this->label1->ForeColor = System::Drawing::Color::Red;
        this->label1->Location = System::Drawing::Point(24, 56);
        this->label1->Name = "Label1";
        this->label1->TabIndex = 0;
        this->label1->Text = "Stop!";
        this->label1->TextAlign =
            System::Drawing::ContentAlignment::MiddleCenter;

        this->button1->Enabled = false;
        this->button1->Location = System::Drawing::Point(56, 88);
        this->button1->Name = "Button1";
        this->button1->Size = System::Drawing::Size(40, 32);
        this->button1->TabIndex = 1;
        this->button1->Text = "stop";

        this->Controls->Add(this->button1);
        this->Controls->Add(this->label1);
        this->Name = "StopSignControl";

        this->MouseEnter +=
            gcnew EventHandler(this, 
                &StopSignControl::StopSignControl_MouseEnter);
        this->MouseLeave +=
            gcnew EventHandler(this, 
                &StopSignControl::StopSignControl_MouseLeave);

    }

private:
    void StopSignControl_MouseEnter(Object^ sender,
        EventArgs^ e)
    {

        label1->Text = label1->Text->ToUpper();
        label1->Font = gcnew System::Drawing::Font(label1->Font->FontFamily,
            14.0F, FontStyle::Bold);
        button1->Enabled = true;
    }

private:
    void StopSignControl_MouseLeave(Object^ sender,
        EventArgs^ e)
    {

        label1->Text = label1->Text->ToLower();
        label1->Font = gcnew System::Drawing::Font(label1->Font->FontFamily,
            12.0F, FontStyle::Regular);
        button1->Enabled = false;
    }

};
[System.Drawing.ToolboxBitmap("c:\\stop.bmp")]
public class StopSignControl:
    System.Windows.Forms.UserControl

{
    internal System.Windows.Forms.Label Label1;
    internal System.Windows.Forms.Button Button1;

    public StopSignControl() : base()
    {        
        this.Label1 = new System.Windows.Forms.Label();
        this.Button1 = new System.Windows.Forms.Button();

        this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) 0));

        this.Label1.ForeColor = System.Drawing.Color.Red;
        this.Label1.Location = new System.Drawing.Point(24, 56);
        this.Label1.Name = "Label1";
        this.Label1.TabIndex = 0;
        this.Label1.Text = "Stop!";
        this.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

        this.Button1.Enabled = false;
        this.Button1.Location = new System.Drawing.Point(56, 88);
        this.Button1.Name = "Button1";
        this.Button1.Size = new System.Drawing.Size(40, 32);
        this.Button1.TabIndex = 1;
        this.Button1.Text = "stop";

        this.Controls.Add(this.Button1);
        this.Controls.Add(this.Label1);
        this.Name = "StopSignControl";
    }

    private void StopSignControl_MouseEnter(object sender, System.EventArgs e)
    {

        Label1.Text.ToUpper();
        Label1.Font = new System.Drawing.Font(Label1.Font.FontFamily, 14.0F, 
        System.Drawing.FontStyle.Bold);
        Button1.Enabled = true;
    }

    private void StopSignControl_MouseLeave(object sender, System.EventArgs e)
    {

        Label1.Text.ToLower();
        Label1.Font = new System.Drawing.Font(Label1.Font.FontFamily, 12.0F, 
        System.Drawing.FontStyle.Regular);
        Button1.Enabled = false;
    }
}
<System.Drawing.ToolboxBitmap("c:\stop.bmp")> _
Public Class StopSignControl
    Inherits System.Windows.Forms.UserControl

    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button

    Public Sub New()
        MyBase.New()
        Me.Label1 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button

        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", _
            12.0F, System.Drawing.FontStyle.Regular, _
            System.Drawing.GraphicsUnit.Point, CType(0, Byte))

        Me.Label1.ForeColor = System.Drawing.Color.Red
        Me.Label1.Location = New System.Drawing.Point(24, 56)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Stop!"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

        Me.Button1.Enabled = False
        Me.Button1.Location = New System.Drawing.Point(56, 88)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(40, 32)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "stop"

        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.Label1)
        Me.Name = "StopSignControl"

    End Sub

    Private Sub StopSignControl_MouseEnter(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles MyBase.MouseEnter

        Label1.Text.ToUpper()
        Label1.Font = New System.Drawing.Font(Label1.Font.FontFamily, _
            14.0F, System.Drawing.FontStyle.Bold)
        Button1.Enabled = True
    End Sub

    Private Sub StopSignControl_MouseLeave(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles MyBase.MouseLeave

        Label1.Text.ToLower()
        Label1.Font = New System.Drawing.Font(Label1.Font.FontFamily, 12.0F, _
             System.Drawing.FontStyle.Regular)
        Button1.Enabled = False
    End Sub

End Class

Comentarios

Puede aplicar un objeto ToolboxBitmapAttribute a un control para que los contenedores, como Microsoft Diseñador de formularios de Visual Studio, puedan recuperar un icono que represente el control. El mapa de bits del icono puede estar en un archivo por sí mismo o incrustado en el ensamblado que contiene el control . El tamaño del mapa de bits que insertó en el ensamblado del control (o almacenar en un archivo independiente) debe ser de 16 a 16. El GetImage método de un ToolboxBitmapAttribute objeto puede devolver la imagen pequeña de 16 a 16 o una imagen grande de 32 a 32 que crea mediante el escalado de la imagen pequeña.

Si desea usar diferentes versiones de los iconos con versiones diferentes del ensamblado, no tiene que modificar para ToolboxBitmapAttribute cada versión. En su lugar, puede declarar el ensamblado con o BitmapSuffixInSameAssemblyAttribute , BitmapSuffixInSatelliteAssemblyAttributey especificar un BitmapSuffix valor de configuración para cada versión del ensamblado. En este caso, un nombre de archivo indicado por se ToolboxBitmapAttribute interpreta con el sufijo de mapa de bits anexado.

Constructores

ToolboxBitmapAttribute(String)

Inicializa un nuevo objeto ToolboxBitmapAttribute con una imagen a partir de un archivo especificado.

ToolboxBitmapAttribute(Type)

Inicializa un nuevo objeto ToolboxBitmapAttribute basado en un mapa de bits de 16 x 16 que se encuentra incrustado como un recurso en un ensamblado especificado.

ToolboxBitmapAttribute(Type, String)

Inicializa un nuevo objeto ToolboxBitmapAttribute basado en un mapa de bits de 16 por 16 que se encuentra incrustado como un recurso en un ensamblado especificado.

Campos

Default

Objeto ToolboxBitmapAttribute cuya imagen pequeña e imagen grande están establecidas en null.

Propiedades

TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.

(Heredado de Attribute)

Métodos

Equals(Object)

Indica si el objeto especificado es un objeto ToolboxBitmapAttribute y si es idéntico a este objeto ToolboxBitmapAttribute.

GetHashCode()

Obtiene un código hash para este objeto ToolboxBitmapAttribute.

GetImage(Object)

Obtiene el objeto Image pequeño asociado a este objeto ToolboxBitmapAttribute.

GetImage(Object, Boolean)

Obtiene el objeto Image pequeño o grande asociado a este objeto ToolboxBitmapAttribute.

GetImage(Type)

Obtiene el objeto Image pequeño asociado a este objeto ToolboxBitmapAttribute.

GetImage(Type, Boolean)

Obtiene el objeto Image pequeño o grande asociado a este objeto ToolboxBitmapAttribute.

GetImage(Type, String, Boolean)

Obtiene el objeto Image pequeño o grande asociado a este objeto ToolboxBitmapAttribute.

GetImageFromResource(Type, String, Boolean)

Devuelve un objeto Image basado en un recurso de mapa de bits que se encuentra incrustado en un ensamblado.

GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.

(Heredado de Attribute)
Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.

(Heredado de Attribute)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Implementaciones de interfaz explícitas

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.

(Heredado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.

(Heredado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).

(Heredado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.

(Heredado de Attribute)

Se aplica a