MergablePropertyAttribute.AllowMerge 属性

获取一个值,该值指示该属性 (Property) 能否与“属性”窗口属于其他对象的属性 (Property) 组合。

**命名空间:**System.ComponentModel
**程序集:**System(在 system.dll 中)

语法

声明
Public ReadOnly Property AllowMerge As Boolean
用法
Dim instance As MergablePropertyAttribute
Dim value As Boolean

value = instance.AllowMerge
public bool AllowMerge { get; }
public:
property bool AllowMerge {
    bool get ();
}
/** @property */
public boolean get_AllowMerge ()
public function get AllowMerge () : boolean

属性值

如果该属性可以与“属性”窗口中属于其他对象的属性进行组合,则为 true;否则为 false

示例

下面的示例检查 MyProperty 是否适合合并。首先,代码通过下面的方法获取 MyProperty 的属性 (Attribute):

  • 检索具有该对象的所有属性 (Property) 的 PropertyDescriptorCollection

  • PropertyDescriptorCollection 进行索引,以获取 MyProperty

  • 将该属性 (Property) 的属性 (Attribute) 保存在属性 (Attribute) 变量中。

然后,代码将 myAttribute 设置为 AttributeCollectionMergablePropertyAttribute 的值,并检查该属性 (Property) 是否适合合并。

' 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
// 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.
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).get_Item
    ("MyPropertyProperty").get_Attributes();

// Checks to see if the property is bindable.
MergablePropertyAttribute myAttribute = 
    ((MergablePropertyAttribute)(attributes.get_Item
    (MergablePropertyAttribute.class.ToType())));

if (myAttribute.get_AllowMerge()) {
    // Insert code here.
}
// Gets the attributes for the property.
var attributes : AttributeCollection = TypeDescriptor.GetProperties(this)["MyPropertyProperty"].Attributes
       
// Checks to see if the property is bindable.
var myAttribute : MergablePropertyAttribute = MergablePropertyAttribute(attributes(MergablePropertyAttribute))
if(myAttribute.AllowMerge){
  // Insert code here.
}

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

MergablePropertyAttribute 类
MergablePropertyAttribute 成员
System.ComponentModel 命名空间
MergablePropertyAttribute 类
Attribute
PropertyDescriptor
AttributeCollection 类
PropertyDescriptorCollection