如果 WinForm 只有一个完全停靠的列表框,则 MouseLeave 不会触发
我有一个只有一个简单列表框的表单。列表框已完全停靠,并且表单的 FormBorderStyle 设置为 None。
当我将 MouseLeave 事件附加到表单时,它不会触发。 (它也不会触发 MouseMove、MouseHover 等。)
但是,如果我取消停靠列表框并调整其大小,以便至少有一部分表单可见,并且如果我将鼠标移到表单的可见部分上,则所有鼠标事件都会再次触发。
即使表单仅由完全停靠的列表框组成,如何让表单接收鼠标事件?
谢谢
I have a Form with only a simple listbox. The listbox is Full-docked and the Form's FormBorderStyle is set to None.
When I attach a MouseLeave event to a form, it does not fire. (It also does not fire MouseMove, MouseHover etc.)
However, if I undock the listbox and resize it so at least a part of the form is visible and if I move mouse over the visible part of the form, all mouse events fire again.
How to get the form to receive mouse events even if it's consisted only of a full-docked listbox?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不应该触发,因为您的鼠标没有进入表单,而是进入列表框。所以你应该在列表框控件中使用 MouseLeave 事件
It shouldnt fire bacause your mouse didnt enter to form on, it enters on listbox. So you should use MouseLeave event in listbox control
我认为这是不可能的。因为控件将处理事件,所以它不会被绕过到窗体。
I don't think it is possible. Because the control will handle the events it won't be bypassed to Form.