Unable to add customized icons to toolbox for my User Controls

Posted on 2006-06-02
Last Modified: 2008-02-07
I have a project with many User Controls. Now, I'm trying to use customized icons in the toolbox for my User Controls. Whatever I do, I'm unable to replace the standard "wheel" icon using C# in Visual Studio 2005 Version 8.0.50727.42  (RTM.050727-4200).

Basically, this is what I try to do:
1) Add a 16 color, 16x16 bitmap file to my project. The file name is UserControl1.bmp.
2) Change the Build Action for the bitmap file to Embedded Resource
3) Add the ToolboxBitmap attribute to the component
4) Clean and rebuild the project

My TollboxBitmap attribute looks like this:

namespace ComponentTest {
  [ToolboxBitmap(typeOf(UserControl1), "ComponentTest.UserControl1.bmp")]
  public partial class UserControl1 : UserControl {

However, this doesn't work. I still see the standard "wheel" icon in the toolbox.

To make sure I no resource naming problems I copied the bitmap file to the root of drive d: and changed ToolboxBitmap attribute as follows.

namespace ComponentTest {
  public partial class UserControl1 : UserControl {

This doesn't work too!

In addition I tried to do similar things with Visual Basic but didn't succeed as well.

I'm using Visual Studio 2005 (English setup) on a German edition of Windows XP Professional SP2.
Question by:pgloor
    LVL 96

    Expert Comment

    by:Bob Learned
    What I found was this:

    1) Add a bitmap to the assembly with the same name as the control (i.e UserControl1.bmp)
    2) Change the Build Action for the bitmap to 'Embedded Resource'
    3) Rebuild the assembly
    4) Recheck the Toolbox bitmap

    LVL 11

    Accepted Solution

    you will only have icons on the toolbox, if you compile your control as classlibrary and add that assembly to your toolbox.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now