1.c# WinForm在加载时把焦点设在按钮上

this.AcceptButton = button1;

这样在WinForm窗口中,

按钮的状态会变成窗口的默认按钮,

只要按下Enter键,就会触发按钮的单击事件

这种效果与按钮获得焦点类似.

 当然,加个button1.Focus();更好。

2.c# WinForm在加载时把焦点设在textBox上

两种方法:

1 在Load中设置 
this.ActiveControl = this.textBox;

2 this.textBox.Focus(); 
但在Form_Load设置会无效,可在Form_Paint()中设置.c# WinForm加载焦点

两种方法:

1 在Load中设置 
this.ActiveControl = this.textBox;

2 this.textBox.Focus(); 
但在Form_Load设置会无效,可在Form_Paint()中设置.c# WinForm加载焦点

相关文章:

  • 2021-06-29
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2021-07-23
  • 2021-09-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
相关资源
相似解决方案