Hiding inherited properties

How to hide inherited properties in C#

When inheriting from another component/control it is sometimes desirable to remove some of the properties you are inheriting from the property inspector.

This is achieved with a ControlDesigner, like so

public class MyNameSpace.MyControlDesigner: System.Windows.Forms.Design.ControlDesigner
{
  public override void PostFilterProperties(IDictionary properties)
  {
    properties.Remove("NameOfProperty1");
    properties.Remove("NameOfProperty1");
  }
}

The second step is to associate this designer with your control, like so

[System.ComponentModel.Designer(typeof(MyNameSpace.MyControlDesigner))]
public class MyNameSpace.MyControl: ..........
{
  etc
}

 

Share this article!

Follow us!

Find more helpful articles: