C#-防止鼠标滚轮在面板中滚动 [英] c# - prevent mousewheel scrolling in panel
本文介绍了C#-防止鼠标滚轮在面板中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想防止鼠标滚轮在带有滚动条的面板中滚动,请问如何做到这一点?
I want to prevent scrolling with the mousewheel in a panel with a scrollbar, how can ido this?
我已经看到了这个建议,但是它不起作用:
I have seen this suggested, but it's not working:
panel.MouseWheel += new MouseEventHandler(MouseWheel);
void MouseWheel(object sender, MouseEventArgs e) {
((HandledMouseEventArgs)e).Handled = true;
}
推荐答案
尝试继承自己的Panel,然后注释掉OnMouseWheel调用:
Try inheriting your own Panel and just comment out the OnMouseWheel call:
public class WheelessPanel : Panel {
protected override void OnMouseWheel(MouseEventArgs e) {
// base.OnMouseWheel(e);
}
}
这篇关于C#-防止鼠标滚轮在面板中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文