private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (textBox1.Text.Trim() != "")
            {
                if //敲回车键      ....这里怎么写 ?
                {
                    button2.Focus();
                }
            }
        }

解决方案 »

  1.   

    e.key == 回车(这里应该是一个枚举值,msdn上看看吧)
      

  2.   

    if (e.KeyChar == 13)
      

  3.   

    if (textBox1.Text.Trim() != "")
    {
        if (e.KeyChar == (char)13)
        {
            button2.Focus();
        }
    }
      

  4.   

    好了,应该是:if (e.KeyChar == 13)
    ...谢谢各位好心。
    我其实只是需要那么一点点提示...刚从Delphi转行过来学 C# .net
      

  5.   

    晕,又是delphi,最最最最最讨厌delphi了,转了好。
      

  6.   

    if (textBox1.Text.Trim() != null)
                {
                    if (e.KeyCode==Keys.Enter )
                    {
                        textBox2.Focus();
                    }
                }
      

  7.   

    private void textBox1_KeyDown(object sender, KeyEventArgs e)
            {
                if (textBox1.Text.Trim() != null)
                {
                    if (e.KeyCode==Keys.Enter )
                    {
                        textBox2.Focus();
                    }
                }        }
      

  8.   

    private void textBox1_KeyDown(object sender, KeyEventArgs e)
            {
                if (textBox1.Text.Trim() != "")
                {
                    //Enter
                    if (e.KeyCode==Keys.Enter)
                    {
                        textBox2.Focus();
                    }
                }        }