After much effort and time, I've gotten the collection editor to properly work with a collection property (Items) on a control I've written. The only problem I am having now is that when I delete the control in the designer, the components that were assigned to the Items property are not being deleted with the control.
For instance, if you create a TabControl and add multiple TabPage components to the TabPages property, then delete the TabControl, the TabPage components disappear with it. When I delete my control, the items are not deleted. They remain in the designer generated code and in the drop down list at the top of the property grid.
Some declarations:
If anyone has any tips or suggestions they would be appreciated.
For instance, if you create a TabControl and add multiple TabPage components to the TabPages property, then delete the TabControl, the TabPage components disappear with it. When I delete my control, the items are not deleted. They remain in the designer generated code and in the drop down list at the top of the property grid.
Some declarations:
C#:
// Collection Item Class Declaration
[DesignTimeVisible(false), ToolboxItem(false)]
public class CollectionItem:Component
{
}
// Collection Class Declaration
public class Collection:IList<CollectionItem>, IList
{ // The designer uses the non-generic IList implementation
} // to manage the collection at design time.
// Collection Property Declaration
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), // Treat property as collection
Editor(typeof(CollectionEditor), typeof(System.Drawing.Design.UITypeEditor) )] // Edit with the generic collection editor
public Collection Items { get { return items; } }
If anyone has any tips or suggestions they would be appreciated.