Solved

Yet another saga of the failing ToolboxBitmap

Posted on 2009-03-31
6
388 Views
Last Modified: 2012-05-06
Attempting to get an icon/bitmap to be displayed with my UserControl, but failing miserably.
1.) There is a bit map for this control "ctrlBankBitSW.bmp
2.) The bit map has been set to a build oaction of "Embedded Resource"
3.) The project is set to "Class Library"

What am I missing?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
 
namespace libSigCntrl
{
   //[ToolboxBitmap(@"ctrlBankBitSW.bmp")]
   public partial class ctrlBankBitSW : UserControl
   {
      public ctrlBankBitSW()
      {
         InitializeComponent();
      }
   }
}

Open in new window

0
Comment
Question by:graber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 14

Expert Comment

by:jjardine
ID: 24035301
Looks like the Toolbox Attribute is commented out?
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24038699
How to: Provide a Toolbox Bitmap for a Control
http://msdn.microsoft.com/en-us/library/4wk1wc0a.aspx from microsoft
rest all the samples on the net were saying about giving the fully qualified path for the bitmap but the 3rs sample from microsoft did not use that approach
try, it might work
0
 
LVL 2

Author Comment

by:graber
ID: 24040350
sorry about that jjardine... the comment was intentional.. I failed to remove before posting.  But even with the comment it still fails.
namespace libSigCntrl
{
   [ToolboxBitmap(typeof(ctrlBitSW),@"ctrlBitSW.bmp")]
   public partial class ctrlBitSW : UserControl
   {
      public ctrlBitSW()
      {
         InitializeComponent();
      }
   }
}
 
namespace libSigCntrl
{
   [ToolboxBitmap(typeof(ctrlBankBitSW),"ctrlBankBitSW")]
   public partial class ctrlBankBitSW : UserControl
   {
      public ctrlBankBitSW()
      {
         InitializeComponent();
      }
   }
}

Open in new window

testimg.jpg
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 2

Author Comment

by:graber
ID: 24053138
According to a Microsoft MSDN form for C# and http://www.bobpowell.net/toolboxbitmap.htm
the source should look like the code Snippet

But I still don't show the images for either of the UserControls
ctrlBitSW.cs
namespace libSigCntrl
{
   [ToolboxBitmap(typeof(ctrlBitSW_res), "libSigCntrl.ctrlBitSW.bmp")]
   public partial class ctrlBitSW : UserControl
   {
      public ctrlBitSW()
      {
         InitializeComponent();
      }
   }
}
 
internal class ctrlBitSW_res{}
------------
ctrlBankBitSW.cs
namespace libSigCntrl
{
   [ToolboxBitmap(typeof(ctrlBankBitSW_res), "libSigCntrl.ctrlBankBitSW.bmp")]
   public partial class ctrlBankBitSW : UserControl
   {
      public ctrlBankBitSW()
      {
         InitializeComponent();
      }
   }
}
internal class ctrlBankBitSW_res { }

Open in new window

testimg.jpg
0
 
LVL 2

Accepted Solution

by:
graber earned 0 total points
ID: 24103177
The particulars the developement enviorment:
Microsoft Visual Studio 2005
Version 8.0.50727.867  (vsvista.050727-8600)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: Professional
Microsoft Visual C# 2005   77626-009-2070057-41395
Microsoft Visual C# 2005
Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1 (KB926601)  
This service pack is for Microsoft Visual Studio 2005 Professional Edition - ENU.
Update for Microsoft Visual Studio 2005 Professional Edition - ENU (KB932232)  
This Update is for Microsoft Visual Studio 2005 Professional Edition - ENU.

Well the explaination is: It's a bug.  
But the good news is there is a workaround.  The reason that it works will require some more investigation on my part but this will work.

1.) Add a bitmap to your project space with the same name as the class that it will be used to represent it.  Once you've added it it will be right above the class that will be using it.
2.) Add the end of class to use the bit map add:
     internal class <name>_res{}
     The <name> is what ever you called the class followed by "_res{}".
3.) Add the ToolBoxBitmap as follows:
     [ToolboxBitmap(typeof(<name>_res), "<project name>.<name>.bmp")]
4.) After compiling right click on the "Toolbox" palette and choose the "Choose Item" option. Then when the "Choose Toolbox Items" Dialog appears select "Browse".  Locate the dll for the control you are developing and select "Open".

The bitmap that you created for your control wil show up on the "Toolbox Palette"
0
 
LVL 2

Author Comment

by:graber
ID: 24134545
5.) On the properties for the bmp file change the Build Action Option to "Embedded Resource"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question