Does anyone know why the following does not leave me with a Custom ToolboxBitmap. I have included a 16 x 16 Bitmap called C_Button as an Embedded Resource in the Library. I have a set of controls in the library all with their own Custom bitmaps, but I just get the default Gear bitmap. Is this a restriction because it is an Express Version
All comments gratefully received.
namespace CcNet2005
{
[ToolboxBitmap(typeof(C_Button))]
public partial class C_Button : System.Windows.Forms.Button
{
// Some Code
}
}

ToolboxBitmap problem
BradleyB
I read the entry from Tonn again closer and figured this out to some small degree. If I do what he said and choose items and do a browse to my actual .dll I get my controls importing in and they have correct icons. I think this is a problem with visual studio, but this is at least a work around.
meowbaby7
This worked great for me too. Some notes:
1. Add internal class resfinder { } once - in one of your classes.
2. ClassLibrary1 is the Default namespace that appears in your Project->Properties property sheet. Use Reflect to double check the full names of the bitmaps in the resource file. If there are no resources, see #3 below.
3. Don't forget to change the Build Action to Embed Resource in the Properties for each bitmap file.
Leo Vildosola
i'm having exactly the same problem. I'm using VS2005PRO and I can't get a custom icon in the toolbox... I'm searching all over the internet, but can't find a solution... If you find a solution, please provide it to the forum. I think more people are having this problem....
Steve Jo
I fixed it by the following code, now the icon appears on VB6
[
ComRegisterFunction] public static void ComRegister(Type t){
using (RegistryKey subkey = key.CreateSubKey("DefaultIcon")){
string path = Assembly.GetAssembly(typeof(MyControl.Class1)).Location;subkey.SetValue(
"", path + ",0");}
using (RegistryKey subkey = key.CreateSubKey("ToolBoxBitmap32")){
string path = Assembly.GetAssembly(typeof(MyControl.Class1)).Location;subkey.SetValue(
"", path + ",1");}
.
.
.
}
venkat456
I have tried your suggestion on controls that are based on existing windows form controls as well as those that are based on the UserControl Class. No luck.
Am I missing something fundamental
Could there be something else that I need to do beyond using the correct constructor
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.
plankton
Anyone know how I can get Microsoft to answer the question
Is there anyone from Microsoft checking these threads
Kiran9999
Victim of the same problem, i have been trying to get the bitmap since 2 days, tried all possible ways, no use..
I think some body from microsoft should answer this question.
Thanks
RossAu42
I tried all the ways to have an Icon for my control but I never get it work on VB 6.0. always its an empty icon
cementboot
Hi StoneTheCrows_,
Could it be that you are attempting all this from within the same solution
If so, please note that control attributes behave differently at "authoring time" compared to "run-time". Ask no further. After having spent several days on this matter, I still don't understand why this should be a problem.
Try starting a brand new solution, containing a new windows application.
Import your library into the toolbox by:
> right-clicking on the toolbox,
> selecting "choose Items.." from the popup menu,
> select the ".NET Frameworks Components" tab,
> and browse to your assembly.
FYI
I tried this on Visual Studio 2005 pro. There may be differences using the Express edition.
Good luck,
Tonn
chall3ng3r
Is this normal for .NET assemblies Or am I missing something fundametal
Gary Jones
Pront
Visual Basic:
I have project with assembly name Tools, Root namespace Tools. All embeded resources (thos bitmaps) are stored in the ResourcesFolder. My control is in namespace declared Namespace Windows.Forms, so effective namespace is Tools.Windows.Forms. Class is named TransparentLabel. The only way that worked for me was: Bitmap name is Windows.Forms.TransparentLabel.bmp. Attribute is applied
Namespace Windows.Forms
<ToolboxBitmap(GetType(TransparentLabel), "TransparentLabel.bmp")> _
Public Class TransparentLabel : Inherits Label
Reinsouled
Try another overloaded constructor where you can specify name of your embedded icon resource file:
[ToolboxBitmap(typeof(C_Button), "your_button.bmp")]
gordon LI
Write your control class code like this:
using System;
using System.Drawing;
using System.Windows.Forms;
internal class resfinder { }
namespace MyControls
{
[ToolboxBitmap(typeof(resfinder), "ClassLibrary1.MyButton.bmp")]
public class MyButton : Button
{
}
}
The "resfinder" class is a trick to let the GetImageFromResource() method find the bitmap resource in the proper namespace. This is necessary because I made the namespace for the control ("MyControls") different from the default namespace of the class library ("ClassLibrary1"). The resfinder type reference forces .NET to look for the bitmap resource in "ClassLibrary1.MyButton.bmp" rather than "MyControls.ClassLibrary1.MyButton.bmp".
Build the project. Open the project that will use your control. Right-click the tool box and select "Choose items...". Click on Browse and select the ClassLibrary1.dll assembly. You should now see the MyButton control with the proper bitmap.