EventDescriptorCollection.Find(String, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the description of the event with the specified name in the collection.
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
Parameters
- name
- String
The name of the event to get from the collection.
- ignoreCase
- Boolean
true
if you want to ignore the case of the event; otherwise, false
.
Returns
The EventDescriptor with the specified name, or null
if the event does not exist.
Examples
The following code example finds a specific EventDescriptor. It prints the type of component for this EventDescriptor in a text box. It requires that button1
and textBox1
have been instantiated on a form.
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
Remarks
Note
The HostProtectionAttribute attribute applied to this class has the following Resources property value: Synchronization. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.