C#按Enter键触发按钮点击事件
private void richTextBox2_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { // button2.Focus(); button1_Click(sender, e); } if (e.KeyChar == System.Convert.ToChar(13)) { e.Handled = true; } }
private void richTextBox2_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { // button2.Focus(); button1_Click(sender, e); } if (e.KeyChar == System.Convert.ToChar(13)) { e.Handled = true; } }