views:

41

answers:

1

I've created a UserControl called CatalogBrowser which has a property ListedFamilies that exposes the currently listed Family objects in the control. Here's the code for the property.

public List<Family> ListedFamilies
    {
        get
        {
            List<Family> returnList = new List<Family>();
            foreach (Object obj in this.familyObjectListView.Objects)
            {
                returnList.Add((Family)obj);
            }
            return returnList;
        }
        set 
        {
            this.familyObjectListView.ClearObjects();
            this.familyObjectListView.Objects = value;
        }
    }

Now in a Form where I am using this control I keep having a problem with Visual Studio adding the following line in the Form's designer file.

this.catalogBrowserControl1.ListedFamilies = ((System.Collections.Generic.List<SOMLib.Family>)(resources.GetObject("catalogBrowserControl1.ListedFamilies")));

This causes my program to crash because I don't have a (or want) a resource in my project to initialize the value of this collection property. How can I keep Visual Studio from automatically trying to initialize this property?

+2  A: 

One trick is to add the [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] attribute to your property.

Kevin Pullin