简体   繁体   中英

User Control and List<Class>

i am trying to use Property Editor for my user control but it doesn't work.

if i set the property in the form load if works, but if i want to use the property editor it don't save my changes (when i click again in the property editor it comes clear)

this is how i define the property in my user control:

private List<Field> _searchField;

public List<Field> SearchField
{
    get { return _searchField ?? (_searchField = new List<Field>()); }
}

You need to apply DesignerSerializationVisibility attribute to your property with DesignerSerializationVisibility.Content .

This tells the code generator to produces code for the contents of the object, rather than for the object itself. It helps in code generation for types other than primitive types.

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<int> SearchField { get { return _searchField ?? (_searchField = new List<int>()); } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM