代碼如下:
方法如下:
聲明一個事件:
Num_DiscountAmount.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;
}
}
還有 第三方控件 DevExpress.XtraEditors.SpinEdit ,如何禁用鼠標中間鍵 ?
方法如下:
聲明事件: (SpinEdit1.Controls[0] as DevExpress.XtraEditors.TextBoxMaskBox).MouseWheel += new MouseEventHandler(Frm_MouseWheel);
編寫事件:
void Frm_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta != 0)
DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;
}