NumericUpDown控件默认的情况下,会自动响应鼠标的轮轮事件,滚轮滚动时,数值自增或自减。
在某些情况下,并不希望NumericUpDown控件响应鼠标的滚动事件。
解决办法:
private void Form1_Load(object sender, EventArgs e)
{
numericUpDown1.MouseWheel += numericUpDown1_MouseWheel;
}
///
/// 取消滚轮事件
///
///
///
void numericUpDown1_MouseWheel(object sender, MouseEventArgs e)
{
HandledMouseEventArgs m_HME = e as HandledMouseEventArgs;
if (m_HME != null)
{
m_HME.Handled = true;
}
}