EventDescriptorCollection.Find 方法

获取集合中具有指定名称的事件的说明。

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

语法

声明
Public Overridable Function Find ( _
    name As String, _
    ignoreCase As Boolean _
) As EventDescriptor
用法
Dim instance As EventDescriptorCollection
Dim name As String
Dim ignoreCase As Boolean
Dim returnValue As EventDescriptor

returnValue = instance.Find(name, ignoreCase)
public virtual EventDescriptor Find (
    string name,
    bool ignoreCase
)
public:
virtual EventDescriptor^ Find (
    String^ name, 
    bool ignoreCase
)
public EventDescriptor Find (
    String name, 
    boolean ignoreCase
)
public function Find (
    name : String, 
    ignoreCase : boolean
) : EventDescriptor

参数

  • name
    要从集合中获取的事件的名称。
  • ignoreCase
    如果要忽略事件的大小写,则为 true;否则为 false

返回值

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

备注

提示

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

示例

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

Private Sub FindEvent()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Sets an EventDescriptor to the specific event.
    Dim myEvent As EventDescriptor = events.Find("Resize", False)
    
    ' Prints the event name and event description.
    textBox1.Text = myEvent.Name & ": " & myEvent.Description
End Sub 'FindEvent
private void FindEvent() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
 
    // Sets an EventDescriptor to the specific event.
    EventDescriptor myEvent = events.Find("Resize", false);
 
    // Prints the event name and event description.
    textBox1.Text = myEvent.Name + ": " + myEvent.Description;
 }
private:
   void FindEvent()
   {
      // Creates a new collection and assigns it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Sets an EventDescriptor to the specific event.
      EventDescriptor^ myEvent = events->Find( "Resize", false );
      
      // Prints the event name and event description.
      textBox1->Text = String::Concat( myEvent->Name, ": ", myEvent->Description );
   }
private void FindEvent()
{
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);

    // Sets an EventDescriptor to the specific event.
    EventDescriptor myEvent = events.Find("Resize", false);

    // Prints the event name and event description.
    textBox1.set_Text(myEvent.get_Name() + ": " 
        + myEvent.get_Description());
} //FindEvent

平台

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

请参见

参考

EventDescriptorCollection 类
EventDescriptorCollection 成员
System.ComponentModel 命名空间
EventDescriptor 类
TypeDescriptor