List property in a user control

Hello !!!!

I have implemented a user control (names MyUserControl) which have many properties. One of these properties is a typed List.

As I add MyUserControl to a windows form, I have properties which are in the properties editor. When I click on the button "[...]" near the property which corresponding to my list, I have a list editor ... very good !

But the problem is that although I can add elements in my list with the list editor, nothing is added to the code auto generated. And as a matter of fact, informations (from the list editor) are lost.

How could I solve this problem ?

Thanks very much.

[622 byte] By [Syl20] at [2007-12-16]
# 1
You need to mark the property with DesignerSerializationVisibilityAttribute to indicate to the designer that you want the content of the property to be serialized, not the actual property, for example:

[System.ComponentModel.DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyItems Items
{
get { return _Items; }
}

DavidM.Kean at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified