• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1079
  • Last Modified:

Unable to add customized icons to toolbox for my User Controls

I have a project with many User Controls. Now, I'm trying to use customized icons in the toolbox for my User Controls. Whatever I do, I'm unable to replace the standard "wheel" icon using C# in Visual Studio 2005 Version 8.0.50727.42  (RTM.050727-4200).

Basically, this is what I try to do:
1) Add a 16 color, 16x16 bitmap file to my project. The file name is UserControl1.bmp.
2) Change the Build Action for the bitmap file to Embedded Resource
3) Add the ToolboxBitmap attribute to the component
4) Clean and rebuild the project

My TollboxBitmap attribute looks like this:

namespace ComponentTest {
  [ToolboxBitmap(typeOf(UserControl1), "ComponentTest.UserControl1.bmp")]
  public partial class UserControl1 : UserControl {

However, this doesn't work. I still see the standard "wheel" icon in the toolbox.

To make sure I no resource naming problems I copied the bitmap file to the root of drive d: and changed ToolboxBitmap attribute as follows.

namespace ComponentTest {
  public partial class UserControl1 : UserControl {

This doesn't work too!

In addition I tried to do similar things with Visual Basic but didn't succeed as well.

I'm using Visual Studio 2005 (English setup) on a German edition of Windows XP Professional SP2.
1 Solution
Bob LearnedCommented:
What I found was this:

1) Add a bitmap to the assembly with the same name as the control (i.e UserControl1.bmp)
2) Change the Build Action for the bitmap to 'Embedded Resource'
3) Rebuild the assembly
4) Recheck the Toolbox bitmap

you will only have icons on the toolbox, if you compile your control as classlibrary and add that assembly to your toolbox.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now