Thread Safety

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

Remarks

Properties that are marked with the MergablePropertyAttribute constructor of the value true can be combined with properties belonging to other objects in a Properties window. Properties that are marked with the MergablePropertyAttribute constructor of the value false must be displayed separately. The default is true.

Note When you mark a property with the MergablePropertyAttribute constructor of the value true, the value of this attribute is set to the constant member Yes. For a property marked with the MergablePropertyAttribute constructor of the value false, the value is No. Therefore, when you want to check the value of this attribute in your code, you must specify the attribute as MergablePropertyAttribute.Yes or MergablePropertyAttribute.No.

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

The example presents two different ways of checking the value of the MergablePropertyAttribute. In the second code fragment, the example calls the Equals method with a static (Shared in Visual Basic) value. In the last code fragment, the example uses the AllowMerge property to check the value.

[Visual Basic]
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
' Checks to see if the value of the MergablePropertyAttribute is Yes.
If attributes(GetType(MergablePropertyAttribute)).Equals(MergablePropertyAttribute.Yes) Then
' Insert code here.
End If
' This is another way 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
[C#]
// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
// Checks to see if the value of the MergablePropertyAttribute is Yes.
if(attributes[typeof(MergablePropertyAttribute)].Equals(MergablePropertyAttribute.Yes)) {
// Insert code here.
}
// This is another way to see if the property is bindable.
MergablePropertyAttribute myAttribute =
(MergablePropertyAttribute)attributes[typeof(MergablePropertyAttribute)];
if(myAttribute.AllowMerge) {
// Insert code here.
}
[C++]
// Gets the attributes for the property.
AttributeCollection* attributes =
TypeDescriptor::GetProperties(this)->Item[S"MyProperty"]->Attributes;
// Checks to see if the value of the MergablePropertyAttribute is Yes.
if(attributes->Item[__typeof(MergablePropertyAttribute)]->Equals(MergablePropertyAttribute::Yes)) {
// Insert code here.
}
// This is another way to see if the property is bindable.
MergablePropertyAttribute* myAttribute =
dynamic_cast<MergablePropertyAttribute*>(attributes->Item[__typeof(MergablePropertyAttribute)]);
if(myAttribute->AllowMerge) {
// Insert code here.
}
[JScript]
// Gets the attributes for the property.
var attributes : AttributeCollection = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes
// Checks to see if the value of the MergablePropertyAttribute is Yes.
if(attributes(MergablePropertyAttribute).Equals(MergablePropertyAttribute.Yes)){
// Insert code here.
}
// This is another way to see if the property is bindable.
var myAttribute : MergablePropertyAttribute = MergablePropertyAttribute(attributes(MergablePropertyAttribute))
if(myAttribute.AllowMerge){
// Insert code here.
}

If you marked a class with the MergablePropertyAttribute, use the following code to check the value.