ToolboxBitmapAttribute Constructores

Definición

Inicializa un nuevo objeto ToolboxBitmapAttribute.

Sobrecargas

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.

ToolboxBitmapAttribute(String)

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

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

C#
public ToolboxBitmapAttribute (string imageFile);

Parámetros

imageFile
String

Nombre de un archivo que contiene un mapa de bits de 16 por 16.

Ejemplos

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

C#
[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;
    }
}

Se aplica a

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

ToolboxBitmapAttribute(Type)

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

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.

C#
public ToolboxBitmapAttribute (Type t);

Parámetros

t
Type

Una declaración de tipo Type en cuyo ensamblado que lo define se busca el recurso de mapa de bits.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el ToolboxBitmapAttribute constructor para establecer el icono del control de botón en el icono del cuadro de herramientas de un UserControl elemento denominado StopSignControl3.

C#
[System.Drawing.ToolboxBitmap(typeof(System.Windows.Forms.Button))]
public class StopSignControl3:
    System.Windows.Forms.UserControl

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

    public StopSignControl3() : 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;
    }
}

Comentarios

Este constructor busca un recurso incrustado en el ensamblado que define el tipo especificado por el t parámetro . El constructor busca un recurso denominado namespace.classname.bmp, donde espacio de nombres es el espacio de nombres que contiene la definición de la clase especificada por el t parámetro . Por ejemplo, si ControlA está en Espacio de nombresA en AssemblyA.dll, el constructor busca AssemblyA.dll un recurso denominado NamespaceA.ControlA.bmp.

Se aplica a

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

ToolboxBitmapAttribute(Type, String)

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

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.

C#
public ToolboxBitmapAttribute (Type t, string name);

Parámetros

t
Type

Una declaración de tipo Type en cuyo ensamblado que lo define se busca el recurso de mapa de bits.

name
String

Nombre del recurso de mapa de bits incrustado.

Ejemplos

"En el ejemplo de código siguiente se muestra cómo usar el ToolboxBitmapAttribute constructor para establecer StopSignControl2.bmp como un icono de cuadro de herramientas para .StopSignControl2 En este ejemplo se supone que existe un mapa de bits de 16 por 16 píxeles denominado StopSignControl2.bmp con su propiedad BuildAction establecida en EmbeddedResource.

C#
[System.Drawing.ToolboxBitmap(typeof(StopSignControl2), "StopSignControl2.bmp")]
public class StopSignControl2:
    System.Windows.Forms.UserControl

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

    public StopSignControl2() : 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;
    }
}

Comentarios

Este constructor busca un recurso incrustado en el ensamblado que define el tipo especificado por el t parámetro . El constructor busca un recurso denominado namespace.name, donde espacio de nombres es el espacio de nombres que contiene la definición de la clase especificada por el t parámetro . Por ejemplo, supongamos que ControlA es una clase de NamespaceA en AssemblyA.dll y que ha pasado "MyBitmap.bmp" al name parámetro . A continuación, el constructor busca AssemblyA.dll un recurso denominado NamespaceA.MyBitmap.bmp.

Se aplica a

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9