private void Form1_Deactivate(object sender, EventArgs e) { SetForegroundWindow(this.Handle.ToInt32()); Activate(); BringToFront(); textBox1.Focus(); } private void Form1_Leave(object sender, EventArgs e) { SetForegroundWindow(this.Handle.ToInt32()); Activate(); BringToFront(); textBox1.Focus(); }