Link to home
Start Free TrialLog in
Avatar of graber
graberFlag for United States of America

asked on

Yet another saga of the failing ToolboxBitmap

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

Avatar of jjardine
jjardine
Flag of United States of America image

Looks like the Toolbox Attribute is commented out?
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
Avatar of graber

ASKER

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
Avatar of graber

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of graber
graber
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of graber

ASKER

5.) On the properties for the bmp file change the Build Action Option to "Embedded Resource"