Control.HandleDestroyed Событие
Определение
Происходит в процессе удаления дескриптора элемента управления.Occurs when the control's handle is in the process of being destroyed.
public:
event EventHandler ^ HandleDestroyed;
[System.ComponentModel.Browsable(false)]
public event EventHandler HandleDestroyed;
member this.HandleDestroyed : EventHandler
Public Custom Event HandleDestroyed As EventHandler
- Атрибуты
Примеры
В следующем примере кода показано использование этого элемента.The following code example demonstrates the use of this member. В этом примере обработчик событий сообщает о возникновении события HandleDestroyed.In the example, an event handler reports on the occurrence of the HandleDestroyed event. Этот отчет поможет вам узнать, когда происходит событие и может помочь при отладке.This report helps you to learn when the event occurs and can assist you in debugging. Чтобы сообщить о нескольких событиях или о событиях, которые происходят часто, рассмотрите возможность замены MessageBox.Show на Console.WriteLine или Добавление сообщения в многострочный TextBox.To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.
Чтобы выполнить пример кода, вставьте его в проект, содержащий экземпляр типа, который наследует от Control, например Button или ComboBox.To run the example code, paste it into a project that contains an instance of a type that inherits from Control, such as a Button or ComboBox. Затем присвойте экземпляру имя Control1
и убедитесь, что обработчик событий связан с событием HandleDestroyed.Then name the instance Control1
and ensure that the event handler is associated with the HandleDestroyed event.
private void Control1_HandleDestroyed(Object sender, EventArgs e) {
MessageBox.Show("You are in the Control.HandleDestroyed event.");
}
Private Sub Control1_HandleDestroyed(sender as Object, e as EventArgs) _
Handles Control1.HandleDestroyed
MessageBox.Show("You are in the Control.HandleDestroyed event.")
End Sub
Комментарии
Во время события HandleDestroyed элемент управления по-прежнему является допустимым элементом управления Windows, и Handle может быть создан повторно путем вызова метода RecreateHandle.During the HandleDestroyed event, the control is still a valid Windows control and the Handle can be recreated by calling the RecreateHandle method.
Дополнительные сведения об обработке событий см. в разделе обработка и вызов событий.For more information about handling events, see Handling and Raising Events.