When they press ENTER?

  • Thread starter Thread starter Visually Seen #
  • Start date Start date
V

Visually Seen #

Hi everyone,

How do I say this in C#:

When the user presses the ENTER key on their keyboard, then do this
block of code? (This is a windows form!)

Thanks,

Visually Seen #
 
Visually said:
Hi everyone,

How do I say this in C#:

When the user presses the ENTER key on their keyboard, then do this
block of code? (This is a windows form!)

Thanks,

Visually Seen #

I do this by handling the ProcessCmdKey event...

Chris
 
Hi,

Another possible way is to set the KeyPreview property of the form to true
(so that key presses go first to the form, and then - if not handled by the
forms - to the controls) and then program the KeyPress or KeyDown event of
the form.

Regards - Octavio
 
Back
Top