C# Winforms 文本框的焦点丢失事件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1786369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 20:48:54  来源:igfitidea点击:

Focus Lost event for a Winforms TextBox?

c#.netwinforms

提问by Joan Venge

Which event should I use for this?

我应该为此使用哪个事件?

采纳答案by Joey

Control.Leaveor Control.LostFocus:

Control.LeaveControl.LostFocus

When you change the focus by using the keyboard (?, ?+?, and so on), by calling the Selector SelectNextControlmethods, or by setting the ContainerControl.ActiveControlproperty to the current form, focus events occur in the following order:

  1. Enter
  2. GotFocus
  3. Leave
  4. Validating
  5. Validated
  6. LostFocus

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

  1. Enter
  2. GotFocus
  3. LostFocus
  4. Leave
  5. Validating
  6. Validated

If the CausesValidationproperty is set to false, the Validatingand Validatedevents are suppressed.

当您使用键盘(??+?等)、通过调用SelectSelectNextControl方法或通过将ContainerControl.ActiveControl属性设置为当前窗体来更改焦点时,焦点事件将按以下顺序发生:

  1. 进入
  2. 获得焦点
  3. 离开
  4. 证实
  5. 已验证
  6. 失去焦点

当您使用鼠标或通过调用Focus方法更改焦点时,焦点事件按以下顺序发生:

  1. 进入
  2. 获得焦点
  3. 失去焦点
  4. 离开
  5. 证实
  6. 已验证

如果CausesValidation属性设置为 false,则ValidatingValidated事件将被抑制。

回答by Wil P

Control.LostFocus.

控制。失去焦点。

回答by Martin Robins

'Control.LostFocus'

'Control.LostFocus'