private void pictureBox1_Click(object sender, EventArgs e) { Cursor = Cursors.AppStarting; var frm = new PersonInfo(person); frm.Location = this.ParentForm.Location; frm.StartPosition = FormStartPosition.Manual; frm.FormClosing += delegate { frm.Dispose(); Program.CloseAllButSearch(); }; frm.KeyDown += new KeyEventHandler((s, key) => { if (key.KeyCode == Keys.X) { Console.WriteLine("key pressed"); this.FindForm().Show(); frm.Close(); frm.Dispose(); } }); frm.Show(); this.ParentForm.Hide(); }