Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Yet another saga of the failing ToolboxBitmap

Posted on 2009-03-31
6
Medium Priority
?
391 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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