Share via


EventDescriptorCollection.Find(String, Boolean) Metoda

Definice

Získá popis události se zadaným názvem v kolekci.

public:
 virtual System::ComponentModel::EventDescriptor ^ Find(System::String ^ name, bool ignoreCase);
public virtual System.ComponentModel.EventDescriptor Find (string name, bool ignoreCase);
public virtual System.ComponentModel.EventDescriptor? Find (string name, bool ignoreCase);
abstract member Find : string * bool -> System.ComponentModel.EventDescriptor
override this.Find : string * bool -> System.ComponentModel.EventDescriptor
Public Overridable Function Find (name As String, ignoreCase As Boolean) As EventDescriptor

Parametry

name
String

Název události, která se má získat z kolekce.

ignoreCase
Boolean

truepokud chcete ignorovat případ události; v opačném případě . false

Návraty

Se EventDescriptor zadaným názvem nebo null pokud událost neexistuje.

Příklady

Následující příklad kódu najde konkrétní EventDescriptor. Vytiskne typ komponenty do EventDescriptor textového pole. Vyžaduje, aby button1 se textBox1 ve formuláři vytvořily instance.

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.Text = myEvent.Name + ": " + myEvent.Description;
 }
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

Poznámky

Poznámka

Atribut HostProtectionAttribute použitý pro tuto třídu má následující Resources hodnotu vlastnosti: Synchronization. Atribut HostProtectionAttribute nemá vliv na běžné aplikace (které jsou obvykle spouštěny dvojitým kliknutím na ikonu, zadáním příkazu nebo zadáním adresy URL v prohlížeči). Další informace najdete v HostProtectionAttribute tématu třídy nebo SQL Server atributy programování a ochrany hostitele.

Platí pro

Viz také