vb中关于MouseMove的疑问_(:з」∠)_求救
代码是这样的:PrivateSubForm1_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)H...
代码是这样的:
Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Handles MyBase.MouseMove
If flag Then
Label1.Left = Label1.Left + X
Label1.Top = Label1.Top + Y
End If
End Sub
报错是这样的:
方法“Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)”无法处理事件“Public Event MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs)”,因为它们的签名不兼容。
这是一段我在网上 抄的程序,目的是实现鼠标拖动控件,但是报了个这样的错,这是为什么呀?还有我在网上看到程序很多都没有“Handles ”这一段,但是我所有语句不加这一段就运行不了,这又是为什么呀?求救。。_(:з」∠)_(环境:vs2013) 展开
Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Handles MyBase.MouseMove
If flag Then
Label1.Left = Label1.Left + X
Label1.Top = Label1.Top + Y
End If
End Sub
报错是这样的:
方法“Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)”无法处理事件“Public Event MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs)”,因为它们的签名不兼容。
这是一段我在网上 抄的程序,目的是实现鼠标拖动控件,但是报了个这样的错,这是为什么呀?还有我在网上看到程序很多都没有“Handles ”这一段,但是我所有语句不加这一段就运行不了,这又是为什么呀?求救。。_(:з」∠)_(环境:vs2013) 展开
2个回答
展开全部
Public Class Form1
Dim flag As Boolean
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
flag = True
End Sub
Private Sub Label1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
If flag Then
Label1.Left = Label1.Left + e.X
Label1.Top = Label1.Top + e.Y
End If
End Sub
Private Sub Label1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
flag = False
End Sub
End Class
Dim flag As Boolean
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
flag = True
End Sub
Private Sub Label1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
If flag Then
Label1.Left = Label1.Left + e.X
Label1.Top = Label1.Top + e.Y
End If
End Sub
Private Sub Label1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
flag = False
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询