pgloor
asked on
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(User Control1), "ComponentTest.UserControl 1.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 {
[ToolboxBitmap(@"D:\UserCo ntrol1.bmp ")]
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.
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(User
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 {
[ToolboxBitmap(@"D:\UserCo
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Bob