c#点击按钮-更新编辑控件-编辑控件执行回车keypress事件
参考
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); } }
欢迎讨论,相互学习。
cdtxw@foxmail.com