我正在尝试将MouseMove
和Click
(或MouseClick
)添加到按钮中。最终用户需要能够单击按钮添加元素,还能够将按钮拖动到特定位置以添加元素。我有两个功能独立工作。但是,当我添加两个处理程序时,MouseMove
优先,并且不允许Click
发生(尝试点击显示DragDropEffects.None
效果)。
按钮:
Dim Button As New Button()
'Button Attributes
AddHandler Button.Click, AddressOf Button_Click
AddHandler Button.MouseMove, AddressOf Button_MouseMove
处理程序:
Private Sub Button_MouseMove(sender As Object, e As MouseEventArgs)
Button.DoDragDrop("Button", DragDropEffects.Move)
End Sub
Private Sub Button_Click(sender As Object, e As EventArgs)
'Add Element Function
End Sub
我也尝试使用MouseClick
处理程序,结果相同:
AddHandler Button.MouseClick, AddressOf Button_MouseClick
Private Sub Button_MouseClick(sender As Object, e As MouseEventArgs)
'Add Element Function
End Sub
1。)Click
/ MouseClick
在实施MouseMove
时无法触发的原因是什么?
2.。)使两种功能都可用的正确解决方法是什么?我是否需要执行MouseDown
和MouseUp
处理程序,并跟踪鼠标移动的距离以确定我是否单击或拖动?