EventDescriptorCollection.Find(String, Boolean) Metodo

Definizione

Ottiene la descrizione dell'evento con il nome specificato nell'insieme.

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

Parametri

name
String

Nome dell'evento da ottenere dall'insieme.

ignoreCase
Boolean

true se si desidera ignorare la distinzione fra maiuscole e minuscole dell'evento, in caso contrario false.

Restituisce

L'oggetto EventDescriptor con il nome specificato oppure null se l'evento non esiste.

Esempio

Nell'esempio di codice seguente viene trovato un oggetto specifico EventDescriptor. Stampa il tipo di componente in EventDescriptor una casella di testo. Richiede che button1 e textBox1 sia stata creata un'istanza in un modulo.

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

Commenti

Nota

L'attributo HostProtectionAttribute applicato a questa classe ha il valore della proprietà seguente Resources : Synchronization. L'oggetto HostProtectionAttribute non influisce sulle applicazioni desktop, che in genere vengono avviate facendo doppio clic sull'icona, digitando un comando oppure immettendo un URL in un browser. Per altre informazioni, vedere la HostProtectionAttribute classe o gli attributi di programmazione e protezione host SQL Server.

Si applica a

Vedi anche