ListItemCollection problem in custom ControlDesigner
ASP.NET
1
Posts
1
Posters
0
Views
1
Watching
-
I have created a custom ControlDesigner where I have a Smart Tag with a few DesignerActionPropertyItems. One of these DesignerActionPropertyItems contains a ListItemCollection. My problem is when I use the Smart Tag to add items to the collection, nothing is added to the collection. On the other hand, when I use the property editor to modify the collection, all is well! Below is the code. Thanks in advance. MyControl.cs
\[DefaultProperty("Text")\] \[ToolboxData("<{0}:MyControlrunat=server></{0}:MyControl>")\] \[Designer(typeof(MyControlDesigner),typeof(IDesigner))\] \[ParseChildren(ChildrenAsProperties =true)\] public class MyControl: CompositeControl { \[Bindable(true)\] \[Category("Settings: Value")\] \[PersistenceMode(PersistenceMode.InnerProperty)\] \[EditorAttribute(typeof(ListItemsCollectionEditor), typeof(UITypeEditor))\] \[MergableProperty(false)\] public ListItemCollection Items { get { if (ViewState\["Items"\] == null) ViewState\["Items"\] = new ListItemCollection(); return (ListItemCollection)ViewState\["Items"\]; } } }
MyControlDesigner.cs
public class MyControlDesigner : ControlDesigner { //Properties public override System.ComponentModel.Design.DesignerActionListCollection ActionLists { get { DesignerActionListCollection actions = new DesignerActionListCollection(); actions.AddRange(base.ActionLists); actions.Add(new LabeledControlDesignerActionLists(this)); return actions; } } }
MyControlDesignerActionLists.cs
class MyControlDesignerActionLists: DesignerActionList { private MyControlDesigner \_designer; private MyControl \_control; public MyControlDesignerActionLists(MyControlDesigner designer) : base(designer.Component) { this.\_designer = designer; this.\_control = (Mycontrol)this.\_designer.Component; } public override DesignerActionItemCollection GetSortedActionItems() { DesignerActionItemCollection actions = new DesignerActionItemCollection(); actions.Add( new DesignerActionPropertyItem( "Items",