ListItemCollection for a listbox within a composite control

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default ListItemCollection for a listbox within a composite control

    Thanks in advance to anyone who can help :)

    First, you'll have to pardon my very 'beginner' status on custom controls..

    I'm creating a composite control that includes a listbox, and i want to be
    able to add/remove items within it both in design time and runtime, just as
    the default listbox behaves in the vs.net designer.

    The 'ListItemCollection' property is read-only, and thus I don't know how to
    enable this functionality either in design time or runtime. I tried creating
    a public propery of type 'ListItemCollection' within the composite control,
    yet in the vs.net designer (design time) it ignores any additional items I
    attempt to add to the listbox.

    1 ) If I create a object derived from the Listbox control, can I achieve
    this functionality? If so, how? OR ---
    2) Can I simply do this within the existing composite control? If so how?

    Also, some additional resources explaining the functionality of server
    controls within composite controls would be greatly appreciated...

    I've perused the internet quite a bit but there does not seem to be clear
    explanations available.
    studen771 Guest

  2. Similar Questions and Discussions

    1. Composite dropdownlist control that also displays a listbox????
      This is driving me crazy, I am trying to build a custom dropdownlist that when rendered also displays a listbox next to it. I am going to use the...
    2. Losing Composite Control property that another Composite Control ...
      Hi, I'm creating 2 composite controls in ASP.net. Control 1 is a Search control and control 2 is a Map control. I have added a property...
    3. Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
      I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have...
    4. Composite ListBox Control
      I don't know if I understand you correctly, but why would you want to change the name of your child controls? If you want to ensure that all of...
    5. Using Table control in a custom composite control. Control does not render properly in design time.
      All, I have written a very simple custom composite control that includes a control of type System.Web.UI.WebControls.Table. The control...
  3. #2

    Default Re: ListItemCollection for a listbox within a composite control

    Hi,

    I do not do a terrible amount of web controls, but I would suggest you look
    at exposing a property
    of type ListItemCollection as you did and add the add the Editor attribute
    something like the following:

    [Editor("System.Web.UI.Design.WebControls.ListItems CollectionEditor,System.Design,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
    typeof(UITypeEditor)),
    PersistenceMode(PersistenceMode.InnerDefaultProper ty),
    MergableProperty(false)]
    public virtual ListItemCollection Items
    {
    ...
    }

    I have not tested this, but I hope it at least get you going in the right
    direction.

    --
    Chris Taylor
    [url]http://dotnetjunkies.com/weblog/chris.taylor[/url]
    "studen771" <studen771@discussions.microsoft.com> wrote in message
    news:5E22C93A-A3D1-44DE-AE6F-956C58277AA3@microsoft.com...
    > Thanks in advance to anyone who can help :)
    >
    > First, you'll have to pardon my very 'beginner' status on custom
    > controls..
    >
    > I'm creating a composite control that includes a listbox, and i want to be
    > able to add/remove items within it both in design time and runtime, just
    > as
    > the default listbox behaves in the vs.net designer.
    >
    > The 'ListItemCollection' property is read-only, and thus I don't know how
    > to
    > enable this functionality either in design time or runtime. I tried
    > creating
    > a public propery of type 'ListItemCollection' within the composite
    > control,
    > yet in the vs.net designer (design time) it ignores any additional items
    > I
    > attempt to add to the listbox.
    >
    > 1 ) If I create a object derived from the Listbox control, can I achieve
    > this functionality? If so, how? OR ---
    > 2) Can I simply do this within the existing composite control? If so how?
    >
    > Also, some additional resources explaining the functionality of server
    > controls within composite controls would be greatly appreciated...
    >
    > I've perused the internet quite a bit but there does not seem to be clear
    > explanations available.

    Chris Taylor Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139