日期:2014-05-17  浏览次数:20887 次

如何实现textBox的backspace连续消除
如下图,依次是:textBox1、textBox2、textBox3、textBox4、textBox5
 
http://img.my.csdn.net/uploads/201212/19/1355900386_8024.jpg

使用
private void textBox5_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 8)
            {
                this.textBox5.Text = "";
            }
        }


实现了退格键消除textBox的内容,但如何连续呢?
即:消除textBox5以后,继续使用backspace可以消除textBox4,然后可以继续消除textBox3 ......
------解决方案--------------------
你要怎么连续啊。。。想清除某个文本框的内容,总得先把光标移动到控件上吧,楼主是想鼠标都不要动,直接按空格就按顺序清空文本框内容吗?可以这样

private void textBox5_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 8)
            {
                this.textBox5.Text = "";
                textBox4.Focus();//焦点给textBox4
            }            
        }
private void textBox4_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 8)
            {
                this.textBox3.Text = "";
                textBox4.Focus();//焦点给textBox3
            }            
        }
private void textBox3_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 8)
            {
                this.textBox3.Text = "";
                textBox2.Focus();//焦点给textBox2
            }            
        }
private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 8)
            {
              &n