Windows Forms

Hello All;

I’ve got a problem with windows Forms. I want to know Is there any event which can be raised whenever a key pressed on the form for exampleTab Key.I tested KeyPress event of form but it wasn’t applied.

Any suggestion would be truly appreciated.
Thanks.

[870 byte] By [Ya_aa] at [2007-12-16]
# 1
The problem here is that the currently focused control is processing the key event instead of the Form. But thankfully, there is a way for a Form to "see" the key event before the control: simply set the Form's KeyPreview property to true and set up the Forms Key handling as normal. To avoid problems, you may want to try raising the KeyUp event instead of the KeyPress event, especially for catching the Tab key.

Finally, doing it this way will hopefully be sufficient for you, but like many things, is not always 100% guaranteed to work depending on the given scenario. In these cases (which may not be relevant to you), overriding the PreProcessMessage method of the form would probably be your best bet, though it can be tricky.

Phizz at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
respected sir

thank you for a great help
this thread helps me a lot

nirav_a_parikh at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...