Enter key pressed event handler
Either KeyDown or KeyUp. TextBox tb = new TextBox(); tb.KeyDown += new KeyEventHandler(tb_KeyDown); static void tb_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //enter key is down } }
Either KeyDown or KeyUp. TextBox tb = new TextBox(); tb.KeyDown += new KeyEventHandler(tb_KeyDown); static void tb_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //enter key is down } }