Form.Deactivate 事件

定义

当窗体失去焦点并且不再是活动窗体时发生。

public:
 event EventHandler ^ Deactivate;
public event EventHandler Deactivate;
public event EventHandler? Deactivate;
member this.Deactivate : EventHandler 
Public Custom Event Deactivate As EventHandler 

事件类型

示例

以下示例演示如何使用此成员。 在此示例中,事件处理程序报告事件的发生情况 Deactivate 。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑替换MessageBox.ShowConsole.WriteLine或将消息追加到多行TextBox

若要运行示例代码,请将其粘贴到包含命名Form类型的Form1实例的项目中。 然后,确保事件处理程序与 Deactivate 事件相关联。

private void Form1_Deactivate(Object sender, EventArgs e) {

   MessageBox.Show("You are in the Form.Deactivate event.");
}
Private Sub Form1_Deactivate(sender as Object, e as EventArgs) _ 
     Handles Form1.Deactivate

   MessageBox.Show("You are in the Form.Deactivate event.")

End Sub

注解

可以使用此事件执行任务,例如使用停用表单中的数据更新应用程序中的另一个窗口。

有关处理事件的详细信息,请参阅 处理和引发事件

适用于

另请参阅