我正在尝试覆盖鼠标滚轮控件,以便当鼠标滚轮向上或向下移动时,它只会将 numericupdown 字段中的值增加 1。我相信它当前正在使用存储在控制面板中的内容并增加/减少每次加 3。
我正在使用以下代码。即使 numberOfTextLinesToMove 仅为 1 并且我看到 txtPrice.Value 已按预期填充,其他东西正在覆盖它,因为我设置的值不是 numericupdown 框中显示的值
void txtPrice_MouseWheel(object sender, MouseEventArgs e)
{
int numberOfTextLinesToMove = e.Delta / 120;
if (numberOfTextLinesToMove > 0)
{
txtPrice.Value = txtPrice.Value + (txtPrice.Increment * numberOfTextLinesToMove);
}
else
{
txtPrice.Value = txtPrice.Value - (txtPrice.Increment * numberOfTextLinesToMove);
}
}