各位大虾:
   我想在一个textBox里先 textBox1.text="abc";紧接着让textBox1里执行一个“回车”键操作,不是手工按回车键,是让程序实现,该如何实现?
   模拟键盘?

解决方案 »

  1.   

    使用SendKeys类的Send方法,例子如下:
    // Clicking Button1 causes a message box to appear.
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        MessageBox.Show("Click here!");
    }
    // Use the SendKeys.Send method to raise the Button1 click event 
    // and display the message box.
    private void Form1_DoubleClick(object sender, System.EventArgs e)
    {    // Send the enter key; since the tab stop of Button1 is 0, this
        // will trigger the click event.
        SendKeys.Send("{ENTER}");
    }
      

  2.   

    谢谢lxhvc(lxhvc)
    您提供的代码是MSDN上的例程
    请问我想在TEXTBOX里传送一个ENTER键,该如何实现?
      

  3.   

    textbox有一个keydown事件,判断按键是不是enter,不需换行
      

  4.   

    if(keyData==Keys.Enter)
    {
    你的操作
    }
      

  5.   

    莫非是想分行?textBox1.Text+= "\r\n";
      

  6.   

    private void txtBox_textChange(System.Object sender, System.EventArgs e)
    {
        if(txtBox.text=="abc")
        {
             SendKeys.Send("{ENTER}");
         }
    }大概意思是这样子 没在编辑器写 不知道 能不能调试过。
      

  7.   

    to MasDn(欧总) 
       试过,这样不行