MouseWheel,确定向上和向下滚动事件

时间:2010-03-04 10:06:37

标签: vb.net events handler mousewheel

有没有办法确定鼠标是否使用子画面上的鼠标滚轮处理程序向上或向下滚动?例如

Private Sub PictureBox1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel

if mousewheel.scrollup then
        UserZoom = UserZoom + 0.05
        Me.Refresh()
end if


End Sub

我希望能够根据鼠标是向上还是向下推动来向上或向下调整userzoom的值。任何帮助将不胜感激

2 个答案:

答案 0 :(得分:16)

检查MouseEventArgs的Delta属性:

示例代码:

Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
    If e.Delta > 0 Then
        Trace.WriteLine("Scrolled up!")
    Else
        Trace.WriteLine("Scrolled down!")
    End If
End Sub

答案 1 :(得分:0)

想出来。

e.delta根据鼠标是向上还是向下滚动来传递负值或正值!