C# - 如何防止鼠标滚轮在我的组合框? [英] C# - how do I prevent mousewheel-scrolling in my combobox?

查看:148
本文介绍了C# - 如何防止鼠标滚轮在我的组合框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个组合框,我想阻止用户使用鼠标滚轮滚动这些项目。有没有简单的方法?



(C#,VS2008)

解决方案

使用< ://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousewheel.aspxrel =nofollow noreferrer> MouseWheel 事件为您的ComboBox:

  void comboBox1_MouseWheel(object sender,MouseEventArgs e){
(HandledMouseEventArgs)e).Handled = true;
}

注意:您必须在代码中创建事件:

  comboBox1.MouseWheel + = new MouseEventHandler(comboBox1_MouseWheel); 


I have a combobox and I want to prevent the user from scrolling through the items with the mousewheel.

Is there an easy way to do that?

(C#, VS2008)

解决方案

Use the MouseWheel event for your ComboBox:

void comboBox1_MouseWheel(object sender, MouseEventArgs e) {
    ((HandledMouseEventArgs)e).Handled = true;
}

Note: you'll have to create event in code:

comboBox1.MouseWheel += new MouseEventHandler(comboBox1_MouseWheel);

这篇关于C# - 如何防止鼠标滚轮在我的组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆