PropertyDescriptorCollection 类

.NET Framework 2.0

表示 PropertyDescriptor 对象的集合。

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

public class PropertyDescriptorCollection : IList, IDictionary, ICollection, 
	IEnumerable
J#
public class PropertyDescriptorCollection implements IList, IDictionary, 
	ICollection, IEnumerable
public class PropertyDescriptorCollection implements IList, IDictionary, 
	ICollection, IEnumerable

PropertyDescriptorCollection 是只读的;它不实现添加或移除属性的方法。必须从此类继承以实现这些方法。

使用在 PropertyDescriptorCollection 类中可用的属性,可以对集合内容进行查询。使用 Count 属性确定集合中的元素数。使用 Item 属性按索引号或按名称获取特定属性。

除了属性外,您可以使用 Find 方法来获取集合中具有指定名称的属性的说明。

Note注意

应用于此类的 HostProtectionAttribute 属性 (Attribute) 具有以下 Resources 属性 (Property) 值:SynchronizationHostProtectionAttribute 不影响桌面应用程序(桌面应用程序一般通过双击图标,键入命令或在浏览器中输入 URL 启动)。有关更多信息,请参见 HostProtectionAttribute 类或 SQL Server 编程和宿主保护属性

下面的代码示例使用 button1 上的属性创建新的 PropertyDescriptorCollection。它要求已在窗体上实例化 button1

PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);

J#
PropertyDescriptorCollection properties = 
    TypeDescriptor.GetProperties(button1);

下一个示例在文本框中输出按钮上的所有属性。它要求已在窗体上实例化 button1 和 textBox1

private void MyPropertyCollection() {
    // Creates a new collection and assign it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
 
    // Displays each property in the collection in a text box.
    foreach (PropertyDescriptor myProperty in properties)
       textBox1.Text += myProperty.Name + '\n';
 }

J#
private void MyPropertyCollection()
{
    // Creates a new collection and assign it the properties for button1.
    PropertyDescriptorCollection properties = 
        TypeDescriptor.GetProperties(button1);

    // Displays each property in the collection in a text box.
    for (int iCtr = 0; iCtr < properties.get_Count(); iCtr++) {
        PropertyDescriptor myProperty = properties.get_Item(iCtr);
        textBox1.set_Text(myProperty.get_Name() + '\n');
    }
} //MyPropertyCollection

System.Object 
   System.ComponentModel.PropertyDescriptorCollection

此类型的任何公共静态(Visual Basic 中的  Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、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
.NET Compact Framework
受以下版本支持:2.0、1.0



原文地址:https://msdn.microsoft.com/zh-cn/library/6x5wesx5(VS.80).aspx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值