Solved

Yet another saga of the failing ToolboxBitmap

Posted on 2009-03-31
6
383 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
  • 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 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