Thursday, August 28, 2008

Virtual Cancel Button

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.


1 comment:

kaelynnevallas said...

Borgata Hotel Casino & Spa in Atlantic City | Dr.MCD
Borgata Hotel Casino & 속초 출장샵 Spa is Atlantic 양산 출장안마 City's 포천 출장안마 premiere integrated resort with world-class hotel 수원 출장안마 accommodations. From 고양 출장마사지 world-class casino