C# 回车(键盘)事件


在KeyPress事件中  

  private   void   textBox1_KeyPress(object   sender,   System.Windows.Forms.KeyPressEventArgs   e)   
  {   
  
if(e.KeyChar==(char)13)   
  {   
  
this.textBox2.Focus();   
  }   
  }


===================================================================================
  

private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
     {
        
//if条件检测按下的是不是Enter键
           if(e.KeyCode==Keys.Enter)
           {
                 MessageBox.Show(
"您在textBox1里按下了回车键");
           }
     } 

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/nanwang314/archive/2011/02/10/6176604.aspx

posted @ 2011-05-25 20:53  C#&SQL  阅读(1188)  评论(0)    收藏  举报