DesignerSerializationVisibilityAttribute.Visibility プロパティ

定義

プロパティの値を永続化するかどうかと永続化の方法を決定するときにシリアライザーが使用する基本的なシリアル化モードを示す値を取得します。

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

プロパティ値

DesignerSerializationVisibility 値のいずれか 1 つ。 既定値は、Visible です。

次のコード例は、 の 値を確認する方法をDesignerSerializationVisibilityAttributeMyProperty示しています。 最初に、コードは オブジェクトのすべてのプロパティを持つ を取得 PropertyDescriptorCollection します。 次に、コードが にインデックスを作成 PropertyDescriptorCollection して を取得 MyPropertyします。 次に、このプロパティの属性を返し、属性変数に保存します。

この例では、 の値を確認する 2 つの異なる方法を DesignerSerializationVisibilityAttribute示します。 2 番目のコード フラグメントでは、値を使用して メソッドをEqualsstatic呼び出します。 最後のコード フラグメントでは、 プロパティを Visibility 使用して値を確認します。

// 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

適用対象

こちらもご覧ください