Design-Time Collection Serialization
-
Hello i am trying to override a listview's Items property i have created a new ListItems method that implements a custom UITypEeditor for ListViewItem allowing my to insert my own type that inherits from ListViewItem called ControlItem now sow far all of this seems to work properly however my problem is that when the designer serialized the newly created item it uses the wrong constructor ControlItem controlItem1 = ((ControlItem)(new System.Windows.Forms.ListViewItem(""))); it is calling the constructor of the base class, is there a way for me to ovveride this behavior and tell it my own type to instantiate? i have tried the DesignerSerializationVisibility attribute but it does not seem to work. here is the definition of the ListItems method //[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor(typeof(ControlItemCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))] public ListView.ListViewItemCollection ListItems { get { return Items; } } i would appreciate any help that could be provided. thank you.
-
Hello i am trying to override a listview's Items property i have created a new ListItems method that implements a custom UITypEeditor for ListViewItem allowing my to insert my own type that inherits from ListViewItem called ControlItem now sow far all of this seems to work properly however my problem is that when the designer serialized the newly created item it uses the wrong constructor ControlItem controlItem1 = ((ControlItem)(new System.Windows.Forms.ListViewItem(""))); it is calling the constructor of the base class, is there a way for me to ovveride this behavior and tell it my own type to instantiate? i have tried the DesignerSerializationVisibility attribute but it does not seem to work. here is the definition of the ListItems method //[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor(typeof(ControlItemCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))] public ListView.ListViewItemCollection ListItems { get { return Items; } } i would appreciate any help that could be provided. thank you.
This doesn't really answer your question, but rather than use inheritance to add functionality to the ListView class, why not create a user control that simply consists of a fully-docked ListView? This way, you can expose a Items collection of any type you wish. Admittedly it's more work, but you end up with a better fitting control (rather than simply tacking on new specific behavior to a very generic control). -Phil