Tutorials‎ > ‎C# Tutorials‎ > ‎

Trap Enter Key

posted Mar 28, 2012, 9:00 AM by Tim Key
        private void txtTextbox_KeyPress(object sender, EventArgs e)
        {
            //Trap the enter key
            string info = e.KeyChar.ToString();
            if (info == "\r")
            {
                //Your code here

                //This signals the event that you have managed the outcome
                e.Handled = true;
            }
        }
Comments