PDA

Click to See Complete Forum and Search --> : Visual C# 2005 Express - ToolboxBitmap


StoneTheCrows
Apr 12th, 2006, 02:57 PM
I am woking on a Control Library that I call CcNet2005. Some of the controls are based on exisiting windows forms controls whilst others are based on 'UserControl' or 'Component'. I have included a 16 x 16 Bitmap for each control as an Embedded Resource in the Library and each bitmap is named the same as its target Control.
I cannot seem to get a working ToolboxBitmap for any of the controls in the library, I just get the default Gear bitmap.

Is this a restriction because it is an Express Version?
Am I missing something fundamental?
Could there be something else that I need to do beyond using the correct constructor?

Here is a sample of the ways I have tried to get the ToolboxBitmap to work.

// None of these constructor versions seem to work

namespace CcNet2005
{
[ToolboxBitmap(@"..\Resources\C_DataView.bmp"), Description("CcNet2005 Data View/Edit Control")]
public partial class C_DataView : UserControl
{
#region "The Code"
Some Really Clever stuff ..........
#endregion
}

}

namespace CcNet2005
{
[ToolboxBitmap(typeof(C_DataView)), Description("CcNet2005 Data View/Edit Control")]
public partial class C_DataView : UserControl
{
#region "The Code"
Some Really Clever stuff ..........
#endregion
}

}

namespace CcNet2005
{
[ToolboxBitmap(typeof(C_DataView), "C_DataView"), Description("CcNet2005 Data View/Edit Control")]
public partial class C_DataView : UserControl
{
#region "The Code"
Some Really Clever stuff ..........
#endregion
}

}

:sick:
FYI:
Using Visual C# 2005 Express Edition to create the Control Library.
Have tested the control libary and all controls work as expected other than the problem as described.
Have tried the Control Library in a Windows Application using both Visual C# 2005 Express and Visual Basic 2005 Express Edition. Same Results in both cases.

jmcilhinney
Apr 12th, 2006, 05:58 PM
I believe that your third effort is on the right track but according to the help topic for that constructor you need to precede the resource name with the namespace and also include the extension. I would guess that that would mean it should be:ToolboxBitmap(typeof(C_DataView), "CcNet2005.C_DataView.bmp")

StoneTheCrows
Apr 12th, 2006, 06:19 PM
I believe that your third effort is on the right track but according to the help topic for that constructor you need to precede the resource name with the namespace and also include the extension. I would guess that that would mean it should be:ToolboxBitmap(typeof(C_DataView), "CcNet2005.C_DataView.bmp")

Thanks for the suggestion. Having tried it, no luck unfortunately.

It seems odd that this would be such a difficult thing to resolve. I can't believe that no-one bothers with creating ToolboxBitmaps for their control librarys and yet there seems to be a real issue over getting this one to work. It didn't work during the Beta phases of the Visual Studio product and I just (stupidly) thought that it was going to be resolved in the release version.

When you think back to VB6 and how simple it was then (Select an image from the Properties window) you would have thought that MS would have got this right fairly quickly. That is of course if I am not just being thick and missing some fundamental part of the process!

StoneTheCrows
Apr 21st, 2006, 06:50 PM
I'm 'Bumping' this because the problem is really starting to bug me and I am hoping someone in the know will take pity on me.

Surely this can't be such a big secret.