This example worked for me:
http://www.codeproject.com/csharp/DzCollectionEditor.asp [quoted text, click to view] "Marina" <someone@nospam.com> wrote in message
news:uPGWl52MEHA.1468@TK2MSFTNGP12.phx.gbl...
> Hi, no matter what I do I can't seem to get this to work. I've read every
> post I can find on this, and none of the solutions help.
>
> Basically, I have a collection of objects, that I'd like for users to be
> able to add at design time using the collection editor. Here is the code
for
> the type and collection:
>
> Public Class TestClass
> Private testVal As String
>
> Public Property TestProperty() As String
> Get
> Return testVal
> End Get
> Set(ByVal Value As String)
> testVal = Value
> End Set
> End Property
> End Class
>
> Public Class TestClassCollection
> Inherits CollectionBase
>
> Default Public Overridable Property Item( _
> ByVal index As Integer _
> ) As TestClass
> Get
> Return CType(list(index), TestClass)
> End Get
> Set(ByVal Value As TestClass)
> list(index) = Value
> End Set
> End Property
>
> Public Function Add(ByVal value As TestClass) As Integer
> Dim i As Integer
>
> i = list.Add(value)
>
> Return i
> End Function
> End Class
>
> The class that has the collection property, has this:
>
> Private testCol As New TestClassCollection
> <EditorAttribute(GetType(CollectionEditor),
> GetType(System.Drawing.Design.UITypeEditor))> _
> Public ReadOnly Property TestCollection() As TestClassCollection
> Get
> Return testCol
> End Get
> End Property
>
> So, this does indeed bring up the collection editor, but adding items
> doesn't save, and doesn't do anything.
>
> Doing the same kind of thing, but with the collection containing a visual
> control type, would generate code for the control - but never add it to
the
> collection. So again, it would not persist.
>
> I can't find a clear cut simple example of how this is supposed to work,
and
> like I said, I've tried a ton of other solutions - such as extending the
> CollectionEditor class, etc, etc..
>
> Any one know how this is supposed to work? Or where to find a very basic
> simple working example?
>
> Thanks
>
>