Hi again. I hope you guys don't think that I'm not trying or am lazy due to all the questions I'm asking here.

Does anybody know the KeyChar arguments for the Del and Backspace buttons? I need to put them in a KeyPress event

Also, I'm confused as to how to implement a Control+Z and Control+R KeyPress event... I need to know when the user presses those combinations to so I can perform the required actions (undo/redo).

And if you can throw in the arguments for the Function keys (F1...F12) that would be great.


hi. it's okay, i'm glad to help.

to enable (or disable) the backspace or delete button in a KeyPress event, use the escaped character, so for example, if you want to disable the backspace, you add the folowing to the Keypress event:

char key = e.KeyChar;
if (key != '\b')
     e.Handled = true;

now, to implement button combinations, you first have to set the KeyPreview property on your form to true. this enables your form to get the key events before the controls do.

frmBase.KeyPreview = true;

so, for example you'd like to add the combination 'Ctrl + S' (e.g. to save).

first, set the form event for keypress this way:

this.KeyDown += new KeyEventhandler(this.frmbase_KeyDown);

we're almost there. to make the combination of keys work, we just finish it up like this:

private void frmbase_KeyDown(object sender, KeyEventArgs e)
     if (e.Control && e.KeyCode == Keys.S)
           // enter here the required action or method to execute

note how the if-statement clearly defines the combination of pressed keys.

hope this helped