This documentation is archived and is not being maintained.

ToolboxBitmapAttribute Constructor (Type)

Initializes a new ToolboxBitmapAttribute object based on a 16 x 16 bitmap that is embedded as a resource in a specified assembly.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public ToolboxBitmapAttribute(
	Type t


Type: System.Type
A Type whose defining assembly is searched for the bitmap resource.

This constructor searches for an embedded resource in the assembly that defines the type specified by the t parameter. The constructor searches for a resource named namespace.classname.bmp, where namespace is the namespace containing the definition of the class specified by the t parameter. For example, if ControlA is in NamespaceA in AssemblyA.dll, then the constructor searches AssemblyA.dll for a resource named NamespaceA.ControlA.bmp.

The following code example demonstrates how to use the ToolboxBitmapAttribute constructor to set the icon of the button control to the toolbox icon for a UserControl named StopSignControl3.

public class StopSignControl3:

    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.Name = "StopSignControl";


    private void StopSignControl_MouseEnter(object sender, System.EventArgs e)
        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.Font = new System.Drawing.Font(Label1.Font.FontFamily, 
	    12.0F, System.Drawing.FontStyle.Regular);
        Button1.Enabled = false;


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.