MergablePropertyAttribute.AllowMerge プロパティ

定義

プロパティ ウィンドウ内の他のオブジェクトに属するプロパティとこのプロパティを組み合わせることができるかどうかを示す値を取得します。

public:
 property bool AllowMerge { bool get(); };
public bool AllowMerge { get; }
member this.AllowMerge : bool
Public ReadOnly Property AllowMerge As Boolean

プロパティ値

このプロパティをプロパティ ウィンドウ内の他のオブジェクトに属するプロパティと組み合わせることができる場合は true。それ以外の場合は false

次の例では、 MyProperty がマージに適しているかどうかを確認します。 まず、コードは次の方法で MyProperty の属性を取得します。

  • オブジェクトのすべてのプロパティを含む PropertyDescriptorCollection を取得します。

  • MyPropertyを取得するためにPropertyDescriptorCollectionにインデックスを作成する。

  • このプロパティの属性を attributes 変数に保存します。

次に、コードはmyAttributeAttributeCollectionMergablePropertyAttributeの値に設定し、プロパティがマージに適しているかどうかを確認します。

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

// Checks to see if the property is bindable.
MergablePropertyAttribute^ myAttribute = dynamic_cast<MergablePropertyAttribute^>(attributes[ MergablePropertyAttribute::typeid ]);
if ( myAttribute->AllowMerge )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes =
   TypeDescriptor.GetProperties(this)["MyPropertyProperty"].Attributes;

// Checks to see if the property is bindable.
MergablePropertyAttribute myAttribute = (MergablePropertyAttribute)attributes[typeof(MergablePropertyAttribute)];
if (myAttribute.AllowMerge)
{
    // Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
   TypeDescriptor.GetProperties(Me)("MyPropertyProperty").Attributes
       
' Checks to see if the property is bindable.
Dim myAttribute As MergablePropertyAttribute = _
   CType(attributes(GetType(MergablePropertyAttribute)), _
   MergablePropertyAttribute)
If myAttribute.AllowMerge Then
    ' Insert code here.
End If

適用対象

こちらもご覧ください