Keypress

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I use the Keypress event. So if I hit in the Enter key I went it do
someting. like instead of clicking on a button the enter key will fire up the
program
 
Here is an example to capture the enter key.

protected override bool ProcessCmdKey( ref Message msg, Keys keyData )
{
if( keyData == Keys.Enter )
{
MessageBox.Show( "Enter pressed!" );
return true;
}
return base.ProcessCmdKey( ref msg, keyData );
}


Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html
 
Back
Top