all groups > dotnet windows forms > april 2005 >
You're in the

dotnet windows forms

group:

Form's KeyPreview doesn't work if there is a DataGrid on the form


Form's KeyPreview doesn't work if there is a DataGrid on the form Andrea
4/29/2005 12:00:00 AM
dotnet windows forms:
Hello,

I've to know when a user press these keys: F1, F2, F3 ecc...
I set the KeyPreview=true on the Windows Form but the KeyPress event of
the form is not raised if a DataGrid is on the form.

Is there any workaround?

Re: Form's KeyPreview doesn't work if there is a DataGrid on the form durstin
5/2/2005 4:25:06 PM
The KeyPress event isn't fired for the function keys at all, regardless
whether a datagrid is on the form. The KeyPress event doesn't handle all
the keys that the KeyDown and KeyUp events handle, e.g., the navigation keys
(Insert, Home, etc.), the arrow keys, the function keys, caps lock, print
screen, etc.

Use the KeyUp and/or KeyDown events instead for the function keys. Please
keep in mind that F1 is commonly the Help key, and there is support for help
via the HelpProvider component.


[quoted text, click to view]

AddThis Social Bookmark Button