You can add a Virtual cancel button by using KeyPreview property and Key Down event of Form. Just add Key Down event method implementation for form and Set KeyPreview property as True.
Below is code Details
This.Form.KeyPreviw = true;
private void SettingsForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.DialogResult = DialogResult.Cancel;
}
}
Setting of KeyPreview Property of form, will receive all the keystroke events (KeyPress, KeyDown, KeyUp). After form event handler completed processing the keystroke, the keystroke assigned to the control with focus.By default is false.
Note : If the form doesn’t contains any visible and enable controls then it automatically receive all keyboard events.
For more information
Click Here
This is my first post, Please feel free to give comments if you can send me mail also.