By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Cannot get ToolboxBitmap to work

P: n/a
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.

Mar 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Jeff" wrote:
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.

Mar 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.