简体   繁体   English

如何从“工具箱”中隐藏一个额外的控件?

[英]How to hide an extra control from the "Toolbox"?

Creating a library with new controls.使用新控件创建库。 It has 2 classes "HandySeparator - Basic" and "HandyHSeparator - Derived".它有 2 个类“HandySeparator - Basic”和“HandyHSeparator - Derived”。 The base class inherits the Control class. It contains properties that call the Invalidate() method.基础 class 继承了 Control class。它包含调用 Invalidate() 方法的属性。 In the derived class, inside the OnPaint() method, the element is being drawn.在派生的 class 中,在 OnPaint() 方法内,正在绘制元素。

The catch is that after rebuilding the library, a control with the name of the base class appears in the "Toolbox", but I don't need it there.美中不足的是,重建库后,“工具箱”中出现了一个名为 base class 的控件,但我不需要它。

** HandySeparator ** ** HandySeparator **

  public class HandySeparator : Control {
    private DashStyle dashStyle;
    public DashStyle DashStyle {
      get { return dashStyle; }
      set {
        dashStyle = value;
        Invalidate ();
      }
    }

  ...
  }

** HandyHSeparator ** ** HandyHSeparator **

  public class HandyHSeparator : HandySeparator {
  ...
  
  ... OnPaint(...) {
    /// Draw element
  }

  ...
  }

** HandySeparator ** ** HandySeparator **

  [ToolboxItem(false)]
  public class HandySeparator : Control {
    private DashStyle dashStyle;
    public DashStyle DashStyle {
      get { return dashStyle; }
      set {
        dashStyle = value;
        Invalidate ();
      }
    }

  ...
  }

** HandyHSeparator ** ** HandyHSeparator **

  [ToolboxItem(true)]
  public class HandyHSeparator : HandySeparator {
  ...
  
  ... OnPaint(...) {
    /// Draw element
  }

  ...
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM