Tuesday, June 8, 2010

Catching the enter key in a C# textbox

It's simple, but useful:

     private void textBoxProductKey_KeyPress(object sender, KeyPressEventArgs e)
             {
                 //pressing the enter key, ladies.
                 if (e.KeyChar == 13) {
                     //do your thing

                 }
                 e.Handled = true;
             }


The keyboard code for enter is 13.

No comments:

Post a Comment