Enter key not being captured - not firing KeyDown

S

STom

I monitor the KeyDown event for an edit field on my Winform. I am capturing
the Enter key (in case someone presses it it needs to act like a tab).

This works most of the time, but there is some sequence happening within my
code in other places that makes it so that the 'Enter' key is not captured.
The KeyDown event still fires and I can capture other keys but just not the
enter key.

Is there anything that would make the Enter key not activate the KeyDown
event?

STom
 
E

Erik Moore

I monitor the KeyDown event for an edit field on my Winform. I am capturing the
Enter key (in case someone presses it it needs to act like a tab).

Is the form's AcceptButton property set?
 
S

STom

No. One of the reasons that the forms AcceptButton property is not set to
any button is because within some of the edit fields the users want to be
able to select Enter instead of Tab to get calculations to perform. I know,
wrong way to do it but when they are paying the money you give them what
they want.

Is this what is causing the problem?
 
S

Scott C. Reynolds

STom said:
No. One of the reasons that the forms AcceptButton property is not set to
any button is because within some of the edit fields the users want to be
able to select Enter instead of Tab to get calculations to perform. I know,
wrong way to do it but when they are paying the money you give them what
they want.

Is this what is causing the problem?
for special keys (control keys, arrows, enter) instead of using keydown
or keypress, override ProcessDialogKeys

protected override bool ProcessDialogKeys(Keys keyData)
{
Keys.EnterKey //not sure this is exactly the member, but you'll find it.
}

Scott.
--

____________________________________________
Scott C. Reynolds - Tales From the SharpSide
http://www.scottcreynolds.com
(e-mail address removed)

*****Get your SharpSide Swag!******
http://www.cafepress.com/sharpside/
***********************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top