A. 设置全局变量:
1.定义了个全局变量放本次点击的textbox的名字,默认为空。
2.textbox的Enter事件里SelectAll()一下
3.Click事件里判断全局变量是否是该textbox的名字,如果不是则SelectAll(),然后把textbox的名字赋给全局变量。
4.Leave事件里将全局变量置空。
基本没问题了,有一个小BUG,tab键焦点到textbox时全选,再点一下还是全选,再点才正常。


B.使用委托:       

private void textBox1_Enter(object sender, EventArgs e)
     {
             BeginInvoke((Action)delegate
            {
             textBox1.SelectAll();
             });
      }
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2021-09-27
  • 2021-12-30
相关资源
相似解决方案