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 Получение объекта со всеми свойствами.

  • Индексирование в PropertyDescriptorCollection получение MyProperty.

  • Сохранение атрибутов для этого свойства в переменной атрибутов.

Затем код задает myAttribute значение MergablePropertyAttribute в элементе AttributeCollection и проверяет, соответствует ли свойство слиянию.

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

Применяется к

См. также раздел