Software Development Network>> Visual C#>> How can I make the user able to close the about box with 'Esc' button?
The title says it!
TIA.
Set, if needed, the Form.KeyPreview to true to receive the KeyPress, KeyDown, and KeyUp events even if the current form isn't selected.
You just need to set the About box form's CancelButton property to the OK button.
No need to handle KeyPress, KeyDown or KeyUp events.
How can I make the user able to close the about box with 'Esc' button?
Uri Kluk
{
if (e.KeyData.ToString() == Keys.Escape.ToString())
this.Close();
}
myso
Set, if needed, the Form.KeyPreview to true to receive the KeyPress, KeyDown, and KeyUp events even if the current form isn't selected.
private void MyForm_KeyPress(object sender, KeyPressEventArgs e)
{
if( e.KeyChar == (char)Keys.Escape )
{
this.Close();
}
}
A Chapman
You just need to set the About box form's CancelButton property to the OK button.
No need to handle KeyPress, KeyDown or KeyUp events.