C# 禁用鼠标中间键的方法_技术学院_宜昌市隼壹珍商贸有限公司

您好,欢迎访问宜昌市隼壹珍商贸有限公司

400 890 5375
当前位置: 主页 > 新闻动态 > 技术学院

C# 禁用鼠标中间键的方法

发布时间:2026-01-17  |  点击率:

复制代码 代码如下:
    方法如下:

声明一个事件:

 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;
}

全国统一服务电话

400 890 5375

电子邮箱:879577@qq.com

公司地址:宜昌市西陵区黄河路5号三峡明珠10栋1051室

咨询微信

TEL:13680874598