I have a WinForm app that has other child forms (not mdi). If the user presses \"Esc\" the topmost form should be closed even if it doesn\'t have the focus.
I can u
You could implement a singleton-like pattern in your topmost form, and provide a static property that returns the one instance of itself and simply close it.
public class MainForm : Form
{
private static MainForm mainForm;
public static MainForm { get { return mainForm; } }
public MainForm()
{
mainForm = this;
}
}
// When the ESC key is pressed...
MainForm.MainForm.Close();