Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True ' 设置处理窗体的鼠标事件
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Button1.Location = New Point(e.X, e.Y) ' 将控件的位置设成鼠标的位置,控件即随鼠标移动
End Sub
Me.KeyPreview = True ' 设置处理窗体的鼠标事件
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Button1.Location = New Point(e.X, e.Y) ' 将控件的位置设成鼠标的位置,控件即随鼠标移动
End Sub