DesignerSerializationVisibilityAttribute.Visibility Property

Definition

Gets a value indicating the basic serialization mode a serializer should use when determining whether and how to persist the value of a property.

public:
 property System::ComponentModel::DesignerSerializationVisibility Visibility { System::ComponentModel::DesignerSerializationVisibility get(); };
public System.ComponentModel.DesignerSerializationVisibility Visibility { get; }
member this.Visibility : System.ComponentModel.DesignerSerializationVisibility
Public ReadOnly Property Visibility As DesignerSerializationVisibility

Property Value

One of the DesignerSerializationVisibility values. The default is Visible.

Examples

The following code example shows how to check the value of the DesignerSerializationVisibilityAttribute for MyProperty. First the code gets a PropertyDescriptorCollection with all the properties for the object. Next, the code indexes into the PropertyDescriptorCollection to get MyProperty. Then, the code returns the attributes for this property and saves them in the attributes variable.

This example presents two different ways to check the value of the DesignerSerializationVisibilityAttribute. In the second code fragment, the example calls the Equals method with a static value. In the last code fragment, the example uses the Visibility property to check the value.

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;

// Checks to see if the value of the DesignerSerializationVisibilityAttribute is set to Content.
if ( attributes[ DesignerSerializationVisibilityAttribute::typeid ]->Equals( DesignerSerializationVisibilityAttribute::Content ) )
{
   // Insert code here.
}


// This is another way to see whether the property is marked as serializing content.
DesignerSerializationVisibilityAttribute^ myAttribute = dynamic_cast<DesignerSerializationVisibilityAttribute^>(attributes[ DesignerSerializationVisibilityAttribute::typeid ]);
if ( myAttribute->Visibility == DesignerSerializationVisibility::Content )
{
   // Insert code here.
}
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
 // Checks to see if the value of the DesignerSerializationVisibilityAttribute is set to Content.
 if(attributes[typeof(DesignerSerializationVisibilityAttribute)].Equals(DesignerSerializationVisibilityAttribute.Content)) {
    // Insert code here.
 }
 
 // This is another way to see whether the property is marked as serializing content.
 DesignerSerializationVisibilityAttribute myAttribute = 
    (DesignerSerializationVisibilityAttribute)attributes[typeof(DesignerSerializationVisibilityAttribute)];
 if(myAttribute.Visibility == DesignerSerializationVisibility.Content) {
    // Insert code here.
 }
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyProperty").Attributes

' Checks to see if the value of the DesignerSerializationVisibilityAttribute
' is set to Content.
If attributes(GetType(DesignerSerializationVisibilityAttribute)).Equals( _
    DesignerSerializationVisibilityAttribute.Content) Then
    ' Insert code here.
End If 

' This is another way to see whether the property is marked as serializing content.
Dim myAttribute As DesignerSerializationVisibilityAttribute = _
    CType(attributes(GetType(DesignerSerializationVisibilityAttribute)), _
    DesignerSerializationVisibilityAttribute)
If myAttribute.Visibility = DesignerSerializationVisibility.Content Then
    ' Insert code here.
End If

Applies to

See also