Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / May 2004

Tip: Looking for answers? Try searching our database.

Design time property collection persistence

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marina - 06 May 2004 14:31 GMT
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
Derrick - 06 May 2004 20:19 GMT
This example worked for me:
http://www.codeproject.com/csharp/DzCollectionEditor.asp

> 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.
[quoted text clipped - 65 lines]
>
> Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.