Export (0) Print
Expand All

DesignerSerializationVisibilityAttribute Class

Specifies the type of persistence to use when serializing a property on a component at design time.

System.Object
  System.Attribute
    System.ComponentModel.DesignerSerializationVisibilityAttribute

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event)>]
type DesignerSerializationVisibilityAttribute =  
    class
        inherit Attribute
    end

The DesignerSerializationVisibilityAttribute type exposes the following members.

  NameDescription
Public methodDesignerSerializationVisibilityAttributeInitializes a new instance of the DesignerSerializationVisibilityAttribute class using the specified DesignerSerializationVisibility value.
Top

  NameDescription
Public propertyTypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Public propertyVisibilityGets a value indicating the basic serialization mode a serializer should use when determining whether and how to persist the value of a property.
Top

  NameDescription
Public methodEqualsIndicates whether this instance and a specified object are equal. (Overrides Attribute.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeReturns the hash code for this object. (Overrides Attribute.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsDefaultAttributeGets a value indicating whether the current value of the attribute is the default value for the attribute. (Overrides Attribute.IsDefaultAttribute().)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public fieldStatic memberContentSpecifies that a serializer should serialize the contents of the property, rather than the property itself. This field is read-only.
Public fieldStatic memberDefaultSpecifies the default value, which is Visible, that is, a visual designer uses default rules to generate the value of a property. This static field is read-only.
Public fieldStatic memberHiddenSpecifies that a serializer should not serialize the value of the property. This static field is read-only.
Public fieldStatic memberVisibleSpecifies that a serializer should be allowed to serialize the value of the property. This static field is read-only.
Top

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.InvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top

When a serializer persists the persistable state of a design mode document, it often adds code to the initialization method of components to persist values of properties that have been set at design time. This happens by default for most basic types, if no attribute has been set to direct other behavior.

With the DesignerSerializationVisibilityAttribute, you can indicate whether the value for a property is Visible, and should be persisted in initialization code, Hidden, and should not be persisted in initialization code, or consists of Content, which should have initialization code generated for each public, not hidden property of the object assigned to the property.

Members that do not have a DesignerSerializationVisibilityAttribute will be treated as though they have a DesignerSerializationVisibilityAttribute with a value of Visible. The values of a property marked as Visible will be serialized, if possible, by a serializer for the type. To specify custom serialization for a particular type or property, use the DesignerSerializerAttribute.

For more information, see Extending Metadata Using Attributes.

The following code example demonstrates the use of a DesignerSerializationVisibilityAttribute set to Content. It persists the values of a public property of a user control, which can be configured at design time. To use the example, first compile the following code into a user control library. Next, add a reference to the compiled .dll file in a new Windows Application project. If you are using Visual Studio, the ContentSerializationExampleControl is automatically added to the Toolbox.

Drag the control from the Toolbox to a form, and set the properties of the DimensionData object listed in the Properties window. When you view the code for the form, code will have been added to the InitializeComponent method of the parent form. This code sets the values of the control's properties to those which you have set in design mode.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft