In Depth Banner
Skip Navigation Links

Select your preferred language

Using PreFilterProperties to remove the BackColor

using System;

using System.ComponentModel;

using System.ComponentModel.Design;

using System.Windows.Forms;

using System.Windows.Forms.Design;

using System.Drawing;

 

namespace WellFormed

{

  /// <summary>

  /// Summary description for AControl.

  /// </summary>

  [Designer(typeof(AControlDesigner))] //associate the designer with the control

  public class AControl : Control

  {

    public AControl()

    {

      //Because the BackColor is always PowderBlue the BackColor property must be removed.

      this.BackColor=Color.PowderBlue;

    }

  }

 

  public class AControlDesigner : ControlDesigner

  {

    public AControlDesigner()

    {

    }

 

    protected override void PreFilterProperties(System.Collections.IDictionary properties)

    {

      base.PreFilterProperties(properties);

    

      //Remove the BackColor property from the list of available properties.

      properties.Remove("BackColor");

    }

 

  }

 

 

}

 

Return to the article. 

Copyright © Bob Powell 2003-2009. All rights reserved