ToolBoxBitmap not showing for custom control

Hi,

I have created a custom control called IFrame. When i complie i get the famous blue defualt gear icon on the toolbox. I then created a new project and added the DLL and i got the control to show up and of course with the default blue bitmap. Now the fun begins: I then went back to the my DLL project and i have tryed all the following permutations and i can't get the bitmap to show up.

O yeah, i created a Bitmap called IFrame.bmp thru the VS 2005 IDE and made it 16x16 with 16 colors. Also made it embeded as well.

Tryed:

[ToolboxBitmap(typeof(IFrame), "IFrame.bmp" )]

[ToolboxBitmap(typeof(IFrame), "IFrame" )]

[ToolboxBitmap(typeof(MyNamespace.IFrame), "IFrame.bmp" )]

[ToolboxBitmap(typeof(IFrame))]

Even tryed: I renamed the bmp file to IFrame.IFrame.bmp

[ToolboxBitmap("IFrame.IFrame.bmp" )]

And yet Even tryed: I right-clicked on my project and added a resource in which i imported the BMP in question here and then tryed all the above and still no go.

NOTE: If i spcify to use a control already defined such as a Label or Button ect.. it works fine. I can even specify the IFrame.bmp using a path to it and that works as such:

[ToolboxBitmap(typeof(Button))] <-- That works

[ToolboxBitmap("c:\IFrame.bmp" )] <-- That works

Thanks for any help i can get as i have tryed everything that on the web so even a "Yeah its a bug will help" :-)

Thanks!



Answer this question

ToolBoxBitmap not showing for custom control

  • EnigMa_AnGeL

    1: not really, just the way it works. Maybe they'll make the toolbar code a little smarter, considering how many people have a problem with it.
    2: dunno, and I don't want to find out. It took me a day to recover from yet another toolbar bug after I worked on that answer. Check this thread for the gory details.


  • BCossa

    Just move it to the bottom of the source code file.


  • Alex Yakhnin - MSFT

    Good God! :-)

    Ok her eis a little update on my findings. The fix like i said works great except in my situation it also causes yet another problem. The problem is that i'm working with the designer and so since my main class is not the first class, i get an error. Following i the error i get and a snipet of code: Thanks for the help

    internal class resfinder{} <--- Note this becomes the first class.

    namespace Gui.IFrame

    {

    [Designer( typeof( Gui.IFrame.IFrameDesigner ) )] <-- Designer does not like this

    [ToolboxItem( true )]

    [ToolboxBitmap( typeof( IFrame ), "IFrame.IFrame.bmp" )]

    public partial class IFrame : System.Windows.Forms.UserControl

    {

    }

    }

    Error:

    The class IFrame can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.


    at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
    at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
    at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
    at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)


  • Cla82

    Good God why didnt i think of that LOL.

    Thanks again!


  • Newbie75

    Hi!

    Obviously most easy rare it is said.
    Its way is correct, but to work right with bitmap embedded, lacks to make the basic one, that I did not find in none forum that I looked for, until discovering on account: it is enough to click the right button of mouse on the icon when it appears as RESOURCE inside of the VIEW SOLUTION/PROJECT and to change the property ACTION for
    "Embedded Resource".
    Then its bitmap will go to work.
    Curious that when you add a Bitmap as Resource, it it does not come automatically as embedded.
    (It forgives me for the bad English, but it is lack of practical.)
    Rodrigo.
    Brasil.


  • Porko

    nobugz,

    Thanks a bunch as that did the trick. I do have 2 questions:

    1) Is this a bug and if so do you know if its fixed in the upcoming SP's

    2) Do i need to do the same thing if i decide to import the bitmap into a resource file instead of having it directly under the solution

    Note: I was having the same problem when i inserted the bitmap into a resx file which i prefer to do.

    Thanks again!


  • simon_56387

    Check my answer on this thread...


  • ToolBoxBitmap not showing for custom control