在 GotFocus 事件中获取 KeyCode?

发布于 2024-10-09 17:46:58 字数 157 浏览 0 评论 0原文

C# WinApps:有什么方法可以检查是否按下了 CTRL-V 之类的东西,但不在 KeyDown、PreviewKeyDown、KeyPress 等事件中?这些正在被我的应用程序中的其他部分占用,而且很难找到它们,所以我认为这个控件可以,让我们检查其 GotFocus 事件中按下的键!是否可以?

C# WinApps: Is there any way that I can check if something like CTRL-V is pressed but not in the KeyDown,PreviewKeyDown,KeyPress,etc ... events? those are being eaten by some other parts in my App and it is so hard to find them so I thought Ok for this contorl lets check the pressed keys in its GotFocus event! Is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈场末日恋爱 2024-10-16 17:46:58

不确定事件被“吃掉”是什么意思。事件可以调用多个处理程序。因此,即使该事件已经被一个处理程序订阅,您也可以使用另一个处理程序订阅它,它应该可以正常工作。

另一种选择是对您正在使用的控件进行子类化并使用该子类。然后,您可以重写 On{event} 方法并用这些方法执行您想要的任何操作(请务必调用基方法以确保原始类的行为仍然存在)。

华泰

Not sure what you mean by the events being "eaten". Events can call multiple handlers. So even if the event is already being subscribed to by one handler, you can subscribe to it with another handler and it should work just fine.

Another option would be to subclass the control you are using and use the subclass instead. Then you can override the On{event} methods and do anything you want with those (be sure to call the base method as well to ensure the behavior of the original class is still in place).

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文