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;
            }
        }

 

posted @ 2020-10-31 03:18  WP-WangPin  阅读(1956)  评论(0编辑  收藏  举报