.NET TextBox – Handling the Enter Key

Add a keypress event and trap the enter key

Programmatically it looks kinda like this:

//add the handler to the textbox
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnterKeyPress);

Then Add a handler in code…

private void CheckEnterKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
        if (e.KeyChar == (char)Keys.Return)

        {
           // Then Do your Thang
        }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)