方法一:1、在InitializeComponent函數中添加如下語句:
this.Deactivate += new System.EventHandler(this.Form1_Deactivate);
2、在form1.cs中編寫以下函數:
private void Form1_Deactivate(object sender, EventArgs e)
{//添加你的代碼
}
方法二:
protected override void OnLostFocus(EventArgs e)
{
//添加你所需的代碼
base.OnLostFocus(e);
}
方法三:
1、在InitializeComponent函數中添加如下語句:
this.LoseFocus += new System.EventHandler(this.Form1_LoseFocus);
2、在vform1.cs中編寫以下函數:
private void Form1_LoseFucus(object sender, EventArgs e)
{//添加你的代碼
}