views:

18

answers:

0

I am working on a WinForms designer hosting project. All controls that will be dropped on the DesignSurface are custom controls that inherit from existing controls.

My DropDownListControl:

[Serializable]
[ToolboxBitmap(typeof(System.Web.UI.WebControls.DropDownList))]
[ListControlSerializerAttribute("asp", "DropDownList")]
public class DropDownList : System.Windows.Forms.ComboBox, IBindableControl, IPropertyFilter
{
    ..... Other Members ....

    [Editor(typeof(ListItemsCollectionEditor), typeof(UITypeEditor))]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public new BindingList<ListItem> Items
    {
        get
        {
            return _Items;
        }
    }
}

public interface IPropertyFilter : ICustomTypeDescriptor
{
    PropertyDescriptorCollection FilterProperties(PropertyDescriptorCollection pdc);
    // What properties should be displayed in the PropertyGrid
    List<string> GetPropertiesToShow();
}

The Items property is a BindingList of type ListItem (Custom ListItem class).

When first time this property is created from PropertyGrid the IComponentChangeService events get fired. But when items are again added or removed the IComponentChangeService events does not fire.

Update: I fired the OnComponentChanged event using the IComponentChangeService in a custom UITypeEditor as a workaround .. but there should be a better way to do this.