聚焦丢失事件一个WinForms文本框?文本框、事件、WinForms

2023-09-03 02:58:23 作者:心野套路深

哪个事件我应该使用这个?

Which event should I use for this?

推荐答案

Control.Leave或Control.LostFocus:

当您使用键盘更改焦点(⇆,⇧ + ⇆,等等),通过调用选择或SelectNextControl方法,或通过设置ContainerControl.ActiveControl属性设置为当前的形式,出现下列顺序焦点事件:

When you change the focus by using the keyboard (⇆, ⇧+⇆, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:    进入    GotFocus    离开    Validating    Validated    引发LostFocus    Enter GotFocus Leave Validating Validated LostFocus

当您使用鼠标或通过调用更改焦点重点方法,会出现下列顺序焦点事件:

When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:

   进入    GotFocus    LostFocus    离开    Validating    Validated    Enter GotFocus LostFocus Leave Validating Validated

如果在CausesValidation属性设置为false,Validating和Validated事件燮pressed。

If the CausesValidation property is set to false, the Validating and Validated events are suppressed.