EventDescriptorCollection.Find(String, Boolean) Метод
Определение
Возвращает описание события с указанным именем в коллекции.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);
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
Параметры
- name
- String
Имя события, извлекаемого из коллекции.The name of the event to get from the collection.
- ignoreCase
- Boolean
Значение true
, если требуется игнорировать событие; в противном случае — значение false
.true
if you want to ignore the case of the event; otherwise, false
.
Возвращаемое значение
Дескриптор EventDescriptor с указанным именем или значение null
, если событие не существует.The EventDescriptor with the specified name, or null
if the event does not exist.
Примеры
В следующем примере кода выполняется поиск конкретного EventDescriptor .The following code example finds a specific EventDescriptor. Он выводит тип компонента для этого EventDescriptor в текстовом поле.It prints the type of component for this EventDescriptor in a text box. Для этого требуется, чтобы button1
textBox1
экземпляр и был создан в форме.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
Комментарии
Примечание
HostProtectionAttributeАтрибут, примененный к этому классу, имеет следующее Resources значение свойства: Synchronization .The HostProtectionAttribute attribute applied to this class has the following Resources property value: Synchronization. Атрибут HostProtectionAttribute не оказывает влияния на настольные приложения (обычно запускаемые двойным щелчком значка, вводом команды или URL-адреса в браузере).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). Дополнительные сведения см. в разделе HostProtectionAttribute класс или SQL Server атрибуты защиты узла.For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.