为什么ToolboxBitmap总是无效?

不知道大家有没有发现, 一直以来, 我们在自定义自己的控件的时候都希望自己的控件能带着一个很个性的图标出现在.NET Visual Studio IDE的ToolBox上, 但是很不幸, 尽管我们照着微软的说法来做了, 给我们的控件添加了属性ToolboxBitmap, 但Toolbox上依然只出现一个呆板的齿轮图标...

原来这一切都是微软的Bug, 在这里有较为详细的说明, 下面就提供该文所说的解决方案:

1. 在根命名空间外部创建一个叫resfinder的internal class

2. 用这个resfinder作为你的控件类型名称

3. 用"<default namespace>.<resourcename>"来指定资源所在位置

例如:

internal class resfinder

{

}

 

namespace ToolboxIconDemo

{

  /// <summary>

  /// Summary description for UserControl1.

  /// </summary>

  [ToolboxBitmap(typeof(resfinder),"Foo.Bitmap1.bmp")]

  public class UserControl1 : System.Windows.Forms.UserControl

  {

原文地址:https://www.cnblogs.com/LeoWong/p/1511321.html