EventDescriptorCollection.Find(String, Boolean) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar beskrivningen av händelsen med det angivna namnet i samlingen.
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
Parametrar
- name
- String
Namnet på händelsen som ska hämtas från samlingen.
- ignoreCase
- Boolean
trueom du vill ignorera fallet med händelsen; annars . false
Returer
Med EventDescriptor det angivna namnet eller null om händelsen inte finns.
Exempel
I följande kodexempel hittas en specifik EventDescriptor. Den skriver ut komponenttypen för detta EventDescriptor i en textruta. Det kräver det button1 och textBox1 har instansierats i ett formulär.
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 );
}
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
Kommentarer
Note
Attributet HostProtectionAttribute som tillämpas på den här klassen har följande Resources egenskapsvärde: Synchronization. Påverkar HostProtectionAttribute inte skrivbordsprogram (som vanligtvis startas genom att dubbelklicka på en ikon, skriva ett kommando eller ange en URL i en webbläsare). Mer information finns i klassen HostProtectionAttribute eller SQL Server Programming and Host Protection Attributes.