7

I have a UserControl in my project called 'UIWizard.cs', and a 24-bit Bitmap named 'UIWizardToolboxBitmap.bmp' that has it's build action set to 'Embedded Resource'. I verified that it does exist in the manifest:

.mresource public BitFlex.Windows.Forms.Resources.UIWizardToolboxBitmap.bmp
{
    // Offset: 0x00000000 Length: 0x00000336
}

I have tried these attribute declarations:

[ToolboxBitmap(typeof(UIWizard), "BitFlex.Windows.Forms.Resources.UIWizardToolboxBitmap.bmp")]
public partial class UIWizard : UserControl {

[ToolboxBitmap(typeof(UIWizard), "UIWizardToolboxBitmap.bmp")]
public partial class UIWizard : UserControl {

[ToolboxBitmap(typeof(UIWizard), "UIWizardToolboxBitmap")]
public partial class UIWizard : UserControl {

When I set my library to 'Release Build' and reference it in another project and add the ToolBox items manually using Choose Items... it still fails to display my bitmap properly. I want to avoid using a absolute path, because this is a source controlled project, and not everyone will be using the same mappings.

MSDN really isn't much help as the documentation on the ToolBoxBitmapAttribute is lacking, and most of what's on the web is pretty vague.

David Anderson
  • 13,558
  • 5
  • 50
  • 76
  • Possible duplicate of [Displaying custom icon for custom control?](http://stackoverflow.com/questions/742781/displaying-custom-icon-for-custom-control) – Arvo Bowen Feb 23 '16 at 16:38

1 Answers1

2

It is all bitmap format.
1. If I remember right we are used 256 colors, 16x16 73DPI bitmap.
2. Also try to add [ToolBoxItem(true)] to your class

Sergey Mirvoda
  • 3,209
  • 2
  • 26
  • 30
  • [ToolboxBitmap(typeof(UIWizard), "Resources.UIWizardToolboxBitmap")] [ToolBoxItem(true)] public partial class UIWizard : UserControl { Works. – David Anderson Aug 17 '10 at 15:11
  • I can not get any of this to save my life! I have done everything suggested and still get that dumb purple gear in the toolbox! Also, I thought is was supposed to be a 16 color, 16x16 pixel? – Arvo Bowen Feb 23 '16 at 16:21
  • Just got it to work. For everyone else that can't get it to work for some reason, make sure you are using the correct namespace! On my new UserControl I imported it from somewhere else and it had a different namespace. I had to change it to the new project's namespace (right click on the project, go to properties, and under the application tab check the "Default namespace". That should match the namespace defined in the code of the new UserControl. – Arvo Bowen Feb 23 '16 at 16:31