在textBox1里输入内容,然后敲回车,定位到下一个textBox1,然后输完再定位到下一个textBox1,所有输入完“确定”按钮处于焦点状态.这个怎么实现.

解决方案 »

  1.   

    举个例子:比如说你在TextBox1回车后,焦点落在TextBox2上,可以这样..在TextBox1的KeyPress事件中:
    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar == (char)Keys.Enter)
                {
                    this.textBox2.Focus();
                }
            }
      

  2.   

    同理在TextBox2回车后,焦点落在TextBox3上...在TextBox2的keyPress事件中写...同上..
      

  3.   

    楼上的虽然能实现要求,但是太麻烦,可以将每个textbox的KeyPress事件都指向这个函数就可以了
    private void textBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    if(e.KeyChar== 13)
    {
             SendKeys.Send("{TAB}");
    }
    }