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

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

问题描述

我有一个组合框,我想阻止用户使用鼠标滚轮滚动项目.

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)

(C#, VS2008)

推荐答案

使用 MouseWheel 事件为您的组合框:

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天全站免登陆