Cannot get ToolboxBitmap to work

G

Guest

Hello,

I have developed a library of controls but for the life of me cannot get
ToolboxBitmapAttribute to work -- my image simply will not display in the
toolbox of any project using my controls.

First, what I have:

Visual Studio 2005, .NET 2.0. An assembly name of "Jfx.Framework" and a
default namespace of "Jfx". All the controls work fine when dropped into
other projects as a reference. The images just do not display in any
toolboxes, even those on my own machine.

In my VS project I have a class named JfxButton under a folder structure of
<Project root>/Jfx/Controls:

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace Jfx.Controls
{
[ToolboxItem(true)]
[ToolboxBitmapAttribute(typeof(JfxButton))] // Other constructors don't
work either
public class JfxButton : System.Windows.Forms.Button
{
....
}
}

Inside this same folder, Jfx/Controls, I have an embedded resource named
JfxButton.bmp which is a 16x16 bitmap. JfxButton.cs and JfxButton.bmp are in
the same folder.

I know that the embedded resource is there because it appears in a call to
Assembly.GetManifestResourceNames() as "Jfx.Jfx.Controls.JfxButton.bmp".
After reading other posts on this topic and, although it doesn't make much
sense to me, I know why the double Jfx is at the beginning.

What I've tried:

All combinations of ToolboxBitmapAttribute constructors *including* just
fully-referencing the path on my hard drive. Cleaning the solution,
rebuilding the solution, re-installing VS2005, even screwing around with
project properties and making the default namespace and assembly name the
same failed to work for me. I tried building the project on another
development machine. I've messed around with a whole variety
ToolboxBitmapAttribute constructors including with and without the typeof,
with and without the string image name, combinations of paths, combinations
of paths and image names, etc.

I found many references to this excellent and promising article
http://www.bobpowell.net/toolboxbitmap.htm. Nevertheless, I couldn't get the
'resfinder' trick to work for me. I tried the gamut of approaches outlined
on that page as well but to no avail.

There are also several references to MSDN articles on this topic (and MSDN
itself) but that darn image simply won't display for me.

I assume I'm missing something somewhere...

Given my 'project structure' above, is there a way to get
ToolboxBitmapAttribute to work or am I going to have to like the gear icon?
If it can work, I sure could use some enlightment on how?

Thank you very much in advance for the time.
 
G

Guest

Jeff said:
Hello,

I have developed a library of controls but for the life of me cannot get
ToolboxBitmapAttribute to work -- my image simply will not display in the
toolbox of any project using my controls.

First, what I have:

Visual Studio 2005, .NET 2.0. An assembly name of "Jfx.Framework" and a
default namespace of "Jfx". All the controls work fine when dropped into
other projects as a reference. The images just do not display in any
toolboxes, even those on my own machine.

In my VS project I have a class named JfxButton under a folder structure of
<Project root>/Jfx/Controls:

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace Jfx.Controls
{
[ToolboxItem(true)]
[ToolboxBitmapAttribute(typeof(JfxButton))] // Other constructors don't
work either
public class JfxButton : System.Windows.Forms.Button
{
...
}
}

Inside this same folder, Jfx/Controls, I have an embedded resource named
JfxButton.bmp which is a 16x16 bitmap. JfxButton.cs and JfxButton.bmp are in
the same folder.

I know that the embedded resource is there because it appears in a call to
Assembly.GetManifestResourceNames() as "Jfx.Jfx.Controls.JfxButton.bmp".
After reading other posts on this topic and, although it doesn't make much
sense to me, I know why the double Jfx is at the beginning.

What I've tried:

All combinations of ToolboxBitmapAttribute constructors *including* just
fully-referencing the path on my hard drive. Cleaning the solution,
rebuilding the solution, re-installing VS2005, even screwing around with
project properties and making the default namespace and assembly name the
same failed to work for me. I tried building the project on another
development machine. I've messed around with a whole variety
ToolboxBitmapAttribute constructors including with and without the typeof,
with and without the string image name, combinations of paths, combinations
of paths and image names, etc.

I found many references to this excellent and promising article
http://www.bobpowell.net/toolboxbitmap.htm. Nevertheless, I couldn't get the
'resfinder' trick to work for me. I tried the gamut of approaches outlined
on that page as well but to no avail.

There are also several references to MSDN articles on this topic (and MSDN
itself) but that darn image simply won't display for me.

I assume I'm missing something somewhere...

Given my 'project structure' above, is there a way to get
ToolboxBitmapAttribute to work or am I going to have to like the gear icon?
If it can work, I sure could use some enlightment on how?

Thank you very much in advance for the time.

I am unsure this is useful information but I'm beginning to think I have a
messed up Visual Studio.NET 2005 installation or something is caches funny.
I tried just hardcoding the paths above as in

[ToolboxBitmapAttribute(@"C:\JfxButton.bmp")]

where C:\JfxButton.bmp is a 16 color 16 x 16 bitmap file and the default
gear icon still is the only one to display for this control. My bitmap icon
simply will not show in the toolbox.

Any suggestions?

Thank you for your time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top