Toolbox icon for user control
-
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
-
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
-
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
-
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
-
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
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
-
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
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, ISupportInitializeled mike
-
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
Say you have a structure like this:
Root
\__ Bin
\__ Controls
\__ Commentbox.cs
\__ CommentBox.bmpYou 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 -
Say you have a structure like this:
Root
\__ Bin
\__ Controls
\__ Commentbox.cs
\__ CommentBox.bmpYou 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 -
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