Enter key press in C#

前端 未结 14 910
臣服心动
臣服心动 2020-12-01 06:06

I tried this code:

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (Convert.ToInt32(e.KeyChar) == 13) 
    {
        MessageBox.S         


        
14条回答
  •  悲&欢浪女
    2020-12-01 06:41

    Also you can do this with keypress event.

     private void textBox1_EnterKeyPress(object sender, KeyEventArgs e)
    
     {
    
      if (e.KeyCode == Keys.Enter)
       {
         // some code what you wanna do
       }
    
    
    }
    

提交回复
热议问题