PropertyDescriptorCollection.Find 方法

来源:互联网 发布:tensorflow gpu 编辑:程序博客网 时间:2024/06/14 10:47
.NET Framework 2.0
其他版本

返回具有指定名称的 PropertyDescriptor,使用布尔值指示是否忽略大小写。

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

语法

C#
C++
VB
public virtual PropertyDescriptor Find (string name,bool ignoreCase)
J#
public PropertyDescriptor Find (String name, boolean ignoreCase)
JScript
public function Find (name : String, ignoreCase : boolean) : PropertyDescriptor

参数

name

要从集合中返回的 PropertyDescriptor 的名称。

ignoreCase

如果要忽略属性名称的大小写,则为 true;否则为 false

返回值

具有指定名称的 PropertyDescriptor,或者如果该属性不存在,则为 空引用(在 Visual Basic 中为 Nothing)。

示例

下面的代码示例查找特定的 PropertyDescriptor。它在文本框中输出此 PropertyDescriptor 的组件类型。它要求已在窗体上实例化 button1 和 textBox1

C#
C++
VB
private void FindProperty() {   // Creates a new collection and assign it the properties for button1.   PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);   // Sets a PropertyDescriptor to the specific property.   PropertyDescriptor myProperty = properties.Find("Opacity", false);   // Prints the property and the property description.   textBox1.Text = myProperty.DisplayName + '\n' + myProperty.Description;}
J#
private void FindProperty(){    // Creates a new collection and assign it the properties for button1.    PropertyDescriptorCollection properties =         TypeDescriptor.GetProperties(button1);    // Sets a PropertyDescriptor to the specific property.    PropertyDescriptor myProperty = properties.Find("Opacity", false);    // Prints the property and the property description.    textBox1.set_Text(myProperty.get_DisplayName() + '\n'         + myProperty.get_Description());} //FindProperty

平台

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

请参见

参考

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

TypeDescriptor


原文地址:https://msdn.microsoft.com/zh-cn/library/system.componentmodel.propertydescriptorcollection.find(v=vs.80).aspx

原创粉丝点击