加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 06:54:13 所属栏目:百科 来源:网络整理
导读:关于 this MSDN page(或任何相关页面),它指出: When you change the focus by using the keyboard,focus events occur in the following order: Enter GotFocus Leave Validating Validated LostFocus 但是,当您使用鼠标引发事件时,订单更改! When you cha
关于 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事件.然而,鼠标事件似乎在由于某种原因进行验证之前提高了.这是为什么?

解决方法

我可以想到的最好的例子是验证中的e.Cancel方面.使用键盘进行导航通常是控制导航类型(包括子级和父级控件).使用鼠标进行表单导航并不总是导致选择控件.例如关闭表单或只需单击控件外(即重新定位表单).当控件外部发生鼠标点击时,并不总是希望进行验证.希望有帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读