c# - KeyEventArgs.Handled 与 KeyEventArgs.SupressKeyPress

标签 c# .net vb.net winforms

使用有什么区别

e.Handled = true

e.SuppressKeyPress = true

我读到过 SuppressKeyPress 调用 e.Handled,但除此之外它还有作用吗?

最佳答案

根据此博客:New keyboard APIs: KeyEventArgs.SuppressKeyPress :

The problem is that "Handled" doesn't take care of pending WM_CHAR messages already built up in the message queue - so setting Handled = true does not prevent a KeyPress from occurring.

In order not to break anyone who has currently got e.Handled = true, we needed to add a new property called SuppressKeyChar. If we went the other way, if "handling" a keydown suddenly started to actually work, we might break folks who accidentally had this set to true.

关于c# - KeyEventArgs.Handled 与 KeyEventArgs.SupressKeyPress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7557442/

相关文章:

C# Socket TCP 发送,消息获取 "stuck"

c# - 如何从字符串中获取字符串,以特定字符串开始和结束

c# - 如何使用 linq to entities 将数据绑定(bind)到 asp.net treeview?

.net - DLL 中未调用 VB.NET 静态构造函数

asp.net - 从类型 'DBNull' 到类型 'String' 的转换无效

c# - 如何在 C# 中使继承的不可变属性可变?

c# - 自动添加/删除联合表中的行

c# - iTextSharp 异常 : PDF header signature not found

c# - 如何构建多目标框架的解决方案?

c# - .Net 中的 PostgreSQL 连接错误