当前位置: 代码迷 >> VB Dotnet >> 为啥父窗体鼠标按下事件无效
  详细解决方案

为啥父窗体鼠标按下事件无效

热度:265   发布时间:2016-04-25 02:24:22.0
为什么父窗体鼠标按下事件无效
   
 Private Sub Form2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If Button = 3 Then
            MsgBox("Error encountered while trying to open file," & vbCrLf & "please retry.", vbExclamation, "Text Editor")
        End If
End Sub

只有父窗体时无效,创建子窗体也无效。

请老师指点。
------解决方案--------------------
在form1里调用form2后:
   Dim ff As New Form2()
        ff.Show()
在form2里
 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tools()
    End Sub

    Private Sub Form2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        If e.Clicks Then
            MsgBox("Error encountered while trying to open file," & vbCrLf & "please retry.", vbExclamation, "Text Editor")
        End If
    End Sub
    Private Sub tools()

    End Sub

  相关解决方案