--- title: "How to: Provide a Toolbox Bitmap for a Control" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "Toolbox [Windows Forms], adding bitmaps for custom controls" - "custom controls [Windows Forms], Toolbox bitmaps" - "bitmaps [Windows Forms], custom controls" ms.assetid: 0ed0840a-616d-41ba-a27d-3573241932ad author: jillre ms.author: jillfra manager: jillfra --- # How to: Provide a Toolbox Bitmap for a Control If you want to have a special icon for your control appear in the **Toolbox** of Visual Studio, you can specify a particular image by using the . This class is an *attribute*, a special kind of class you can attach to other classes. For more information about attributes, see [Attributes overview (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/concepts/attributes/index) for Visual Basic or [Attributes (C#)](https://docs.microsoft.com/dotnet/csharp/programming-guide/concepts/attributes/index) for C#. Using the , you can specify a string that indicates the path and file name for a 16 by 16 pixel bitmap. This bitmap then appears next to your control when added to the **Toolbox**. You can also specify a , in which case the bitmap associated with that type is loaded. If you specify both a and a string, the control searches for an image resource with the name specified by the string parameter in the assembly containing the type specified by the parameter. ## To specify a Toolbox bitmap for your control 1. Add the to the class declaration of your control before the `Class` keyword for visual Basic, and above the class declaration for Visual C#. ```vb ' Specifies the bitmap associated with the Button type. Class MyControl1 ' Specifies a bitmap file. End Class _ Class MyControl2 End Class ' Specifies a type that indicates the assembly to search, and the name ' of an image resource to look for. Class MyControl End Class ``` ```csharp // Specifies the bitmap associated with the Button type. [ToolboxBitmap(typeof(Button))] class MyControl1 : UserControl { } // Specifies a bitmap file. [ToolboxBitmap(@"C:\Documents and Settings\Joe\MyPics\myImage.bmp")] class MyControl2 : UserControl { } // Specifies a type that indicates the assembly to search, and the name // of an image resource to look for. [ToolboxBitmap(typeof(MyControl), "MyControlBitmap")] class MyControl : UserControl { } ``` 2. Rebuild the project. > [!NOTE] > The bitmap does not appear in the Toolbox for autogenerated controls and components. To see the bitmap, reload the control by using the **Choose Toolbox Items** dialog box. For more information, see [Walkthrough: Automatically Populating the Toolbox with Custom Components](walkthrough-automatically-populating-the-toolbox-with-custom-components.md). ## See also - - [Walkthrough: Automatically Populating the Toolbox with Custom Components](walkthrough-automatically-populating-the-toolbox-with-custom-components.md) - [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md) - [Attributes overview (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/concepts/attributes/index) - [Attributes (C#)](https://docs.microsoft.com/dotnet/csharp/programming-guide/concepts/attributes/index)