c#窗体的MouseWheel事件如何写?如何获取鼠标是向上还是向下滚动?

2024-11-01 14:29:07
推荐回答(1个)
回答(1):

private void Form1_Load(object sender, EventArgs e)
{
this.MouseWheel += new MouseEventHandler(Form1_MouseWheel);
}

void Form1_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta > 0)
{
this.Text = "正在向上滚动滑轮";
}
else
{
this.Text = "正在向下滚动滑轮";
}
}