C#禁用numericUpDown控件鼠标中键滚轮消息响应
C#禁用numericUpDown控件鼠标中键滚轮消息响应
numericUpDown_roadgain.MouseWheel += new MouseEventHandler(Num_DiscountAmount_MouseWheel); private void Num_DiscountAmount_MouseWheel(object sender, MouseEventArgs e) { HandledMouseEventArgs h = e as HandledMouseEventArgs; if (h != null) { h.Handled = true; } }
可以使用Lambda写法简化:
numericUpDown_roadgain.MouseWheel += (s,e)=> { HandledMouseEventArgs h = e as HandledMouseEventArgs; if (h != null) { h.Handled = true; } };
不要去跟随消逝的虚无