MergablePropertyAttribute.AllowMerge Eigenschaft
Definition
Ruft einen Wert ab, der angibt, ob diese Eigenschaft in einem Eigenschaftenfenster mit Eigenschaften von anderen Objekten kombiniert werden kann.Gets a value indicating whether this property can be combined with properties belonging to other objects in a Properties window.
public:
property bool AllowMerge { bool get(); };
public bool AllowMerge { get; }
member this.AllowMerge : bool
Public ReadOnly Property AllowMerge As Boolean
Eigenschaftswert
true
, wenn diese Eigenschaft in einem Eigenschaftenfenster mit Eigenschaften von anderen Objekten kombiniert werden kann, andernfalls false
.true
if this property can be combined with properties belonging to other objects in a Properties window; otherwise, false
.
Beispiele
Im folgenden Beispiel wird überprüft, ob MyProperty
zum Zusammenführen geeignet ist.The following example checks to see whether MyProperty
is appropriate to merge. Zuerst ruft der Code die Attribute für ab MyProperty
:First the code gets the attributes for MyProperty
by:
Abrufen eines- PropertyDescriptorCollection Objekts mit allen Eigenschaften für das-Objekt.Retrieving a PropertyDescriptorCollection with all the properties for the object.
Indizierung in PropertyDescriptorCollection , um zu erhalten
MyProperty
.Indexing into the PropertyDescriptorCollection to getMyProperty
.Die Attribute für diese Eigenschaft werden in der Attribut Variablen gespeichert.Saving the attributes for this property in the attributes variable.
Anschließend legt der Code myAttribute
auf den Wert von MergablePropertyAttribute in fest AttributeCollection und überprüft, ob die-Eigenschaft zum Zusammenführen geeignet ist.Then the code sets myAttribute
to the value of the MergablePropertyAttribute in the AttributeCollection and checks whether the property is appropriate to merge.
// 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