首页 > 编程 > C# > 正文

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

2020-01-24 03:34:22
字体:
来源:转载
供稿:网友

复制代码 代码如下:

    方法如下:

声明一个事件:

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表