参考
private void textBox_test1_KeyPress(object sender, KeyPressEventArgs e) { if(e.KeyChar==13) { MessageBox.Show("keyPressed....."); } } private void button2_Click(object sender, EventArgs e) { // this.button1_Click(sender, e);//按钮点击事件函数 // button2.PerformClick(); textBox_test1.Text = ""; // textBox_test1.KeyPress(this, KeyPressEventHandler e); textBox_test1.Text = "abcdeff\r"; } private void textBox_test1_TextChanged(object sender, EventArgs e) { if (System.Text.RegularExpressions.Regex.IsMatch(textBox_test1.Text, @".*\r$")) { KeyPressEventArgs e1 = new KeyPressEventArgs('\r'); textBox_test1_KeyPress(this.textBox_test1, e1); } }