StrataFrame Forum

Creating a user control

http://forum.strataframe.net/Topic2227.aspx

By Scott - 8/17/2006

I know this  a basic question but I can't find any information on how to do this.  I have created a class based on the SFUserControl.  I add a listview to the control.  I now want to expose the listviews columns property on the new usercontrol.  I can expost it at design time but every time I reopen the form any values that were set are gone.  Maybe I just am exposing the property incorrectly.  Any help would be greatly appreciated.

Scott

By Trent L. Taylor - 8/17/2006

When you expose a collection property you have to set the designer serialization to allow for content.  This tells the Visual Studio form designer how to properly set the property when saving to the designer file.  You property will need to look something like this:

/// <summary>
        /// A custom collection exposed to a property sheet.  This sets the designer
        /// serialization to content so it will be properly saved within the form
        /// designer.
        /// </summary>
        /// <remarks></remarks>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public System.Collections.CollectionBase MyCollection
        {
            get
            {
                return _MyCollection;
            }
            set
            {
                _MyCollection = value;
            }
        }

By Scott - 8/17/2006

DesignerSerializationVisibility(DesignerSerializationVisibility.Content)

That was what I needed.  Thanks

By Trent L. Taylor - 8/17/2006

Glad to help Smile