Winform中Keypreview属性与Keypress事件的结合
据我所知,上述情况在以下情况下是不可能的。我在这里详细解释一下。
假设如果我有 Form1 并且我设置它的 Keypreview Property = true 比
“Keyprees、Keydown 和 Keyup” 事件仅适用于 winform不适用于它们的子
对象/组件,例如“textbox”、“ListBox”等。
所以我的问题是:-是否有可能将其用于winforms及其子控件。?
通过将 form1 的 keypreview 属性设置为 true 是否可以同时用于表单和控件?
Or By Any Other Way
As far as I know that above is not possible in below case. I explain it in details here.
Suppose If I have Form1 and I set it’s Keypreview Property = true than the
“Keyprees,Keydown,and Keyup" Events are only works for winform not for their child
objects/components Like “textbox”,”ListBox” etc.
So my question is :- Is there possibility to works it for winforms and it’s child controls.?
Is it possible for both forms and controls by setting form1's keypreview property to true?
Or By Any Other Way
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使您将该属性设置为 true,您仍然能够捕获子控件的事件,但您也能够捕获表单上的“预览”事件,这基本上使您有机会在平台将其转发给子控件。
MSDN 解释是结论性的。
Even if you set that property to true you will still be able to catch the events for the child controls but you will also be able to catch a 'preview' event on the form and this basically gives you the oprtunity to handle the event before the platform forwards it to the child control.
The MSDN explanation is conclusive.