gpt4 book ai didi

c# - 为什么会在不同时间调用 LostFocus 事件?

转载 作者:可可西里 更新时间:2023-11-01 09:14:54 25 4
gpt4 key购买 nike

引用this MSDN page (或有关此事的任何相关页面),它指出:

When you change the focus by using the keyboard, 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 Focus method, focus events occur in the following order:

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

这不会使事件链完全不同吗?我在这里的解释是,键盘链确保一切正常,然后引发 LostFocus 事件。然而,鼠标事件似乎在出于某种原因进行验证之前引发了它。这是为什么?

最佳答案

如上所述:

In the MSDN article you linked worded strong enough? Never use LostFocus, only Leave.

The keyboard navigation must be in this order in order to apply the validations. Those are intended to react to them in order to validate any input strings.

关于c# - 为什么会在不同时间调用 LostFocus 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23093349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com