MergablePropertyAttribute.AllowMerge Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett värde som anger om den här egenskapen kan kombineras med egenskaper som tillhör andra objekt i en Properties window.
public:
property bool AllowMerge { bool get(); };
public bool AllowMerge { get; }
member this.AllowMerge : bool
Public ReadOnly Property AllowMerge As Boolean
Egenskapsvärde
true om den här egenskapen kan kombineras med egenskaper som tillhör andra objekt i en Properties window, annars false.
Exempel
I följande exempel kontrolleras om MyProperty det är lämpligt att slå samman. Först hämtar koden attributen för MyProperty genom att:
Hämtar en PropertyDescriptorCollection med alla egenskaper för objektet.
Indexera till PropertyDescriptorCollection för att hämta
MyProperty.Spara attributen för den här egenskapen i attributvariabeln.
Sedan anger myAttribute koden värdet MergablePropertyAttribute för i AttributeCollection och kontrollerar om egenskapen är lämplig för sammanslagning.
// 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