Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Toolbox icon for user control

Toolbox icon for user control

Scheduled Pinned Locked Moved C#
graphicsdesignhardwarequestionlearning
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hain
    wrote on last edited by
    #1

    I've been tearing my hair out (and I can ill afford that!) for hours trying to associate an icon in the toolbox for a user control that I created. Whatever I do, the icon is always the stock icon (the gear). I created a 16x16 bitmap, and made it an embedded resource in my control. I gave the control class an attribute as follows: [ToolboxBitmap(typeof(CommentBox), "CommentBox.bmp")] public class CommentBox : UserControl I have a test form class, that when I bring it up in design mode, I would like the control to show up in the toolbox (with its correct icon). I have tried the "Choose item..." context menu item in the toolbox to remove the control dll, and then reinsert it...to no avail. Any suggestions what I'm missing? Thanks, Tom

    L L H 3 Replies Last reply
    0
    • H hain

      I've been tearing my hair out (and I can ill afford that!) for hours trying to associate an icon in the toolbox for a user control that I created. Whatever I do, the icon is always the stock icon (the gear). I created a 16x16 bitmap, and made it an embedded resource in my control. I gave the control class an attribute as follows: [ToolboxBitmap(typeof(CommentBox), "CommentBox.bmp")] public class CommentBox : UserControl I have a test form class, that when I bring it up in design mode, I would like the control to show up in the toolbox (with its correct icon). I have tried the "Choose item..." context menu item in the toolbox to remove the control dll, and then reinsert it...to no avail. Any suggestions what I'm missing? Thanks, Tom

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      what version of Visual Studio are you using? It's possible that you have to create a custom control to associate a custom icon with it.

      led mike

      H 1 Reply Last reply
      0
      • L led mike

        what version of Visual Studio are you using? It's possible that you have to create a custom control to associate a custom icon with it.

        led mike

        H Offline
        H Offline
        hain
        wrote on last edited by
        #3

        VS 2008, Mike. Actually, I just want an icon for the tool box.

        L 1 Reply Last reply
        0
        • H hain

          VS 2008, Mike. Actually, I just want an icon for the tool box.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          hain wrote:

          Actually, I just want an icon for the tool box.

          That's what I'm talking about. I seem to remember in VS2005 (which I am still using) that you can't associate a custom Icon to a User Control. You may need to do a Custom Control if you want that feature.

          led mike

          H 1 Reply Last reply
          0
          • L led mike

            hain wrote:

            Actually, I just want an icon for the tool box.

            That's what I'm talking about. I seem to remember in VS2005 (which I am still using) that you can't associate a custom Icon to a User Control. You may need to do a Custom Control if you want that feature.

            led mike

            H Offline
            H Offline
            hain
            wrote on last edited by
            #5

            Other than having a protected override void OnPaint(PaintEventArgs pe) method, what makes a custom control "custom"? I tried inheriting my control from System.Forms.Control, rather than UserControl. Still no luck. :((

            modified on Thursday, March 13, 2008 12:54 PM

            L 1 Reply Last reply
            0
            • H hain

              Other than having a protected override void OnPaint(PaintEventArgs pe) method, what makes a custom control "custom"? I tried inheriting my control from System.Forms.Control, rather than UserControl. Still no luck. :((

              modified on Thursday, March 13, 2008 12:54 PM

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              hain wrote:

              what makes a custom control "custom"?

              It's not that it's "custom" it's that it is not a UserControl. It implements one of more interfaces that provide various integration capacity with Visual Studio. http://msdn2.microsoft.com/en-us/library/ms180794(VS.80).aspx[^] here is what I have in VS2005 that works for an extenderProvider

              [ProvideProperty("ShowMRUList", typeof(ToolStripMenuItem)),
                  ToolboxItem(true), ToolboxBitmap( typeof(ToolStrip))]
                  public partial class MRUMenuItem : Component, IExtenderProvider, IDisposable, ISupportInitialize

              led mike

              1 Reply Last reply
              0
              • H hain

                I've been tearing my hair out (and I can ill afford that!) for hours trying to associate an icon in the toolbox for a user control that I created. Whatever I do, the icon is always the stock icon (the gear). I created a 16x16 bitmap, and made it an embedded resource in my control. I gave the control class an attribute as follows: [ToolboxBitmap(typeof(CommentBox), "CommentBox.bmp")] public class CommentBox : UserControl I have a test form class, that when I bring it up in design mode, I would like the control to show up in the toolbox (with its correct icon). I have tried the "Choose item..." context menu item in the toolbox to remove the control dll, and then reinsert it...to no avail. Any suggestions what I'm missing? Thanks, Tom

                L Offline
                L Offline
                leppie
                wrote on last edited by
                #7

                Say you have a structure like this:

                Root
                \__ Bin
                \__ Controls
                \__ Commentbox.cs
                \__ CommentBox.bmp

                You could use the attribute as is above. If however it exists in a another folder, you would have to refer to a type in that folder that has the same namespace of the folder. Example if the BMP was in the Resources folder:

                [ToolboxBitmap(typeof(Resources.ResourceManager), "CommentBox.bmp")]

                xacc.ide - now with IronScheme support
                IronScheme - 1.0 alpha 2 out now

                H 1 Reply Last reply
                0
                • L leppie

                  Say you have a structure like this:

                  Root
                  \__ Bin
                  \__ Controls
                  \__ Commentbox.cs
                  \__ CommentBox.bmp

                  You could use the attribute as is above. If however it exists in a another folder, you would have to refer to a type in that folder that has the same namespace of the folder. Example if the BMP was in the Resources folder:

                  [ToolboxBitmap(typeof(Resources.ResourceManager), "CommentBox.bmp")]

                  xacc.ide - now with IronScheme support
                  IronScheme - 1.0 alpha 2 out now

                  H Offline
                  H Offline
                  hain
                  wrote on last edited by
                  #8

                  Thanks Leppie

                  1 Reply Last reply
                  0
                  • H hain

                    I've been tearing my hair out (and I can ill afford that!) for hours trying to associate an icon in the toolbox for a user control that I created. Whatever I do, the icon is always the stock icon (the gear). I created a 16x16 bitmap, and made it an embedded resource in my control. I gave the control class an attribute as follows: [ToolboxBitmap(typeof(CommentBox), "CommentBox.bmp")] public class CommentBox : UserControl I have a test form class, that when I bring it up in design mode, I would like the control to show up in the toolbox (with its correct icon). I have tried the "Choose item..." context menu item in the toolbox to remove the control dll, and then reinsert it...to no avail. Any suggestions what I'm missing? Thanks, Tom

                    H Offline
                    H Offline
                    hain
                    wrote on last edited by
                    #9

                    I found a great explanation at http://www.bobpowell.net/toolboxbitmap.htm[^] Thanks to all.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups