Results 1 to 2 of 2

Thread: usercontrols... collection value isnt saved when changed at design time

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    usercontrols... collection value isnt saved when changed at design time

    hmm I dont know how to explain it because I dont really know what I'm doing
    I have a class which inherits from CollectionBase. And I have a public property in my usercontrol of that type, so:
    VB Code:
    1. Public myClass:Inherits CollectionBase
    2. End Class
    3.  
    4. ...
    5. 'In user control:
    6. <Browsable (true)> _
    7. Public Property myClass SomeCollection
    8. 'Get, Set....
    9. End Property

    now when I add the usercontrol to my form, and I look at the SomeCollection property, I can click on a little "..." button and the VS Collection Editor shows up... I can add items, but the thing is that the items all disappear after I run the project (so when you check the SomeCollection property, there is no items in the collection anymore, all get cleared)....
    I think I'm doing something fishy here, but I cant figure out what... anyone else ever had this problem?
    let me know if I'm not explaining enough
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    You need to set the DesignerSerializationVisible attribute to Content.

    Also, you might need to create a typeconverter depending of the object in the collection.

    I suggest taking a look at http://www.divil.co.uk/net/articles/...oncontrols.asp. He has a very good explanation and demo of how to use custom collections in usercontrols.

    Hope it helps.

    Good luck.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

Posting Permissions

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



Click Here to Expand Forum to Full Width