void MirInputBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { if (OKButton != null && !OKButton.IsDisposed) { OKButton.InvokeMouseClick(EventArgs.Empty); } e.Handled = true; } else if (e.KeyChar == (char)Keys.Escape) { if (CancelButton != null && !CancelButton.IsDisposed) { CancelButton.InvokeMouseClick(EventArgs.Empty); } e.Handled = true; } }