Search code examples
c#keystroke

executing some code after pressing ENTER key


I have text box for ID. I want user to enter the ID and when he presses the Enter key I fetch some information from that specific ID from database.

how can capture the key stroke as I described?


Solution

  • private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (e.KeyChar == (char) Keys.Return)
        {
            ...
        }
    }