Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ListItemCollection problem in custom ControlDesigner

ListItemCollection problem in custom ControlDesigner

Scheduled Pinned Locked Moved ASP.NET
designsysadminhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fayu
    wrote on last edited by
    #1

    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",
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups