Showing posts with label textbox event. Show all posts
Showing posts with label textbox event. Show all posts

Sunday, May 20, 2018

How To Make an Event when Enter Key is Pressed in a TextBox in C#

First, you have to add a KeyPress event just like the picture show below.



private void txtUsername_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Convert.ToInt32(e.KeyChar) == 13)
            {
               //This is where you will put your code if Enter key is pressed
            }
        }