using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace 123
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  private void Form1_KeyPress(object sender,KeyPressEventArgs e)
  {
  if (e.KeyChar == (char)Keys.Enter)
  label1.Text = "你按下了〈Enter〉键";   
  }  }
}

解决方案 »

  1.   

    原来一直是为每个文本框的KeyPress增加:
            if(e.KeyChar = '\r')   SendKeys.Send("{TAB}");
    最近想想,其实有更简单的方法,把Form的KeyPreView设为true,然后在Form的KeyPress中增加下列代码即可:
           if (e.KeyChar == '\r')
           this.SelectNextControl(this.ActiveControl, true, true, true, true);
      

  2.   

    你把Form的KeyPreview属性改为true试一下
      

  3.   

    设置你的Form的KeyPreview属性。
      

  4.   

    我改成这样的也不行啊
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace 123{
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent(); 
                //textBox1.Text = "你按下了〈Enter〉键";
            }
            private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar == (char)Keys.Enter)
                    textBox1.Text = "你按下了〈Enter〉键";
                else
                    textBox1.Text = "";
            }
        }
    }