UserControl enter key

  • Thread starter Thread starter Chuck Bowling
  • Start date Start date
C

Chuck Bowling

I have a UserControl that contains a TextBox. I can't figure out how to
capture and process the Enter key.

I'm using the event code below...


private void txt_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Return)
{
Blink(Color.Green, 10, 100);
}
}


in my properties I've tried both true and false conditions in
txt.AcceptsReturn
 
Thanks for your help Jayson.

I saw that but can't get it to work. Not sure what's wrong but from what I
can see the txt_KeyUp event isn't even being handled in the UserControl.

Jayson said:
per MSDN:

Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled
by controls automatically. In order to have these keys raise the KeyUp
event, you must override the IsInputKey method in each control on your form.
The code for the override of IsInputKey would need to determine if one of
the special keys is pressed and return a value of true.http://msdn.microsoft.com/library/d...fsystemwindowsformscontrolclasskeyuptopic.asp
 
You can detect the Return Key in the KeyDown Event whatever the settings. Does it have to be in the KeyUp Event?
 
Back
Top