强制不处理事件

发布于 2024-10-09 19:26:39 字数 278 浏览 0 评论 0原文

C# WinApps:主窗体有一个与 CTRL-V 绑定的键...因此,当我按 CTRL-V 时,主应用程序中的任何位置都会运行一些东西..好...但也有一些 MDI 应用程序在该主窗体中打开应用程序...其中一个有一个测试框...啊!现在 CTRL-V 对于文本框也有“粘贴”的含义...所以我将 PreViewKeyDown 添加到文本框并处理它,所以现在它正在粘贴,但它也在执行我定义的主要 CTRL-V 键绑定对于整个应用程序......但我不希望这种情况发生......我能做什么? (我无法更改主应用程序的键绑定。我必须保留它。)

C# WinApps: the main form has a key binding to CTRL-V ...so anywhere in the main app when I press CTRL-V something runs..good ... but also there are some MDI apps that are opening inside this main app ... in one of those there is a test box...ah! now CTRL-V also has a meanining for text box which is "Paste" ... so I added PreViewKeyDown to textbox and handled it, so now it is pasting BUT it is ALSO doing the main CTRL-V key binding that I had defined for the whole app ... but I do no want this to happen.... what can I do? ( I cannot change the key binding od the main app. I must keep it.)

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

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

发布评论

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

评论(1

故人的歌 2024-10-16 19:26:39

您需要注册 Control.KeyDown 事件并将其标记为已处理,以防止该事件进一步传播。

e.Handled = true;

You need to register for the Control.KeyDown event and mark it as handled to prevent further propagation of the event.

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