Specifies whether a visual designer must generate special code to persist the value of a property.
Object
Attribute
MemberAttribute
PersistContentsAttribute
[Visual Basic] Public Class PersistContentsAttribute Inherits MemberAttribute [C#] public class PersistContentsAttribute : MemberAttribute [C++] public __gc class PersistContentsAttribute : public MemberAttribute [JScript] public class PersistContentsAttribute extends MemberAttribute
Typically a visual designer only generates code to set the read/write properties of a new component; it skips read-only properties. Some properties, such as the properties that return collections, are read-only and therefore are skipped. If you want a visual designer to generate code for the read-only property, you must mark the property with PersistContents(true). This would allow you, for example, to add items to a collection.
Members that do not have the PersistContentsAttribute or that are marked with PersistContents(false) will use the default code generation rules; that is, their code will be persisted in the normal fashion. The default is false.
Note When you mark a property with PersistContents(true), the value of this attribute is set to the constant member PersistContentsAttribute.Yes. For a property marked with PersistContents(false), the value is PersistContentsAttribute.No. Therefore, when you want to check the value of this attribute in your code, you must specify the attribute as PersistContentsAttribute.Yes or PersistContentsAttribute.No.
For more information, see TBD and TBD.
Namespace: System.ComponentModel
Assembly: System.dll
System.ComponentModel Namespace | MemberAttribute | PropertyDescriptor