如题,无论你按什么键,光标永久在这个textbox上,求解

解决方案 »

  1.   

    private void textBox1_Leave(object sender, EventArgs e)
    {
        textBox1.Focus();
    }
      

  2.   

    Leave事件里写 this.textbox1.Focus();
      

  3.   

    是啊,你可要试试看;Leave事件就是在光标离开的时候,里面代码是又重新获取光标;所以当你想离开的时候又会重新获得光标。、。。
      

  4.   

    private void textBox1_Leave(object sender, EventArgs e) {     textBox1.Focus(); }
      

  5.   

    如果你觉得leave事件还不保险,你就在键盘事件里面再写上textBox1.Focus(); 
      

  6.   

     private void Form1_Load(object sender, EventArgs e)
            {
              
                this.ActiveControl = this.TextBox1;//窗体加载时让光标定位到输入的文本框
                  
            }