我正在尝试实现自定义拖动操作来对面板进行排序。
我将一个对象分配给 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 参数不返回鼠标当前所在的实际对象?