如果拖动或按住鼠标按钮,发件人不会在 MouseMove 上更新
我正在尝试实现自定义拖动操作来对面板进行排序。
我将一个对象分配给 MouseDown 事件中的变量,并通过在将鼠标拖动到相邻面板上时检查相邻面板的 MouseMove 事件来跟踪其相对位置。
Private Sub ThumbnailMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
_thumbnailMove = DirectCast(sender, Windows.Forms.Control) ‘The object to move
End Sub
问题是 MouseMove 事件的 Sender 参数永远不会改变 – 它总是返回接收 MouseDown 事件的对象。
Private Sub ThumbnailMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Console.WriteLine(sender.Name) 'Always returns the name of the _thumbnailToMove
End Sub
为什么 MouseMove 的 Sender 参数不返回鼠标当前悬停的实际对象?
I am trying to implemented a custom dragging operation to sort panels.
I assign an object to a variable in the MouseDown event and track it’s relative position by examining the MouseMove event of the neighbouring panels as I drag the mouse over them.
Private Sub ThumbnailMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
_thumbnailMove = DirectCast(sender, Windows.Forms.Control) ‘The object to move
End Sub
The problem is that the Sender parameter of the MouseMove event never changes – it always returns the object that received the MouseDown event.
Private Sub ThumbnailMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Console.WriteLine(sender.Name) 'Always returns the name of the _thumbnailToMove
End Sub
Why is the Sender argument of MouseMove not returning the actual object that the mouse is currently over?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要覆盖此行为,请将
Control.Capure
属性设置为False
。现在,MouseMove 事件返回鼠标移动到的实际对象!
To override this behaviour, set the
Control.Capure
property toFalse
.And now the MouseMove event returns the actual object that the mouse moves over!