我需要知道如何在 MouseWheel 事件上确定滚动是向前还是向后(不是垂直或水平)。
panel1.MouseWheel += ZoomIn
public void ZoomIn(object sender, EventArgs e)
{
// Need to know whether the wheel is scrolled forwards or backwards
}
最佳答案
而不是 EventArgs
使用 MouseEventArgs
其中暴露了 Delta
属性(property)。
向下滚动时为负,向上滚动时为正。
panel1.MouseWheel += ZoomIn;
public void ZoomIn(object sender, MouseEventArgs e)
{
if(e.Delta > 0)
{
// The user scrolled up.
}
else
{
// The user scrolled down.
}
}
关于c# - 如何检测鼠标滚轮方向(向前或向后),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49529144/