场景

WinForm 应用,使用了 DevExpress.XtraEditors.TextEdit 控件的 KeyPress 和 Leave 事件。
期望在 TextEdit 上按下回车键或者当 TextEdit 失去焦点时进行相关验证并弹窗提示。

问题

弹窗显示并关闭后,TextEdit 默认是 Focused 的状态,如果这时想切换至其他模块,会触发 Leave 事件进行二次弹窗。

解决

TextEdit 没有 LostFocus 方法。
当进行第一次弹窗时,设置其他控件获取焦点,这样弹窗关闭的时候 TextEdit 就不是 Focused 的状态了。
我这里使用的是 TextEdit 所在的容器 GroupControl:GroupControlName.Focus();

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-19
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案