Enter key not being captured - not firing KeyDown

  • Thread starter Thread starter STom
  • Start date Start date
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
 
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?
 
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?
 
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/
***********************************
 
Back
Top