c#在Trackbar上禁用ScrollWheel [英] c# Disable ScrollWheel on Trackbar
本文介绍了c#在Trackbar上禁用ScrollWheel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用鼠标滚轮在轨道栏上禁用值change?
当界面滚动时,用户可以错误地更改跟踪栏值
我正在使用Windows窗体c#。
我找不到没有属性停止此事件..
How can I disable the valuechange with mouse wheel on trackbars? When scrolling down on the interface users can change trackbar values by mistake I'm using Windows forms c#. I couldn't find no property to stop this event..
推荐答案
我解决了这个问题:
正常的事件声明..
I solved the issue with this: With normal event declaration..
Control = new TrackBar();
Control.MouseWheel += Control_MouseWheel;
private void Control_MouseWheel(object sender, MouseEventArgs e)
{
((HandledMouseEventArgs)e).Handled = true;
}
使用匿名方法
var Control = new TrackBar();
Control.MouseWheel += new MouseEventHandler(delegate(object sender, MouseEventArgs e)
{
((HandledMouseEventArgs)e).Handled = true;
});
它的作用是防止进一步执行..
What it does is to prevent further execution..
编辑:
使用Labda表达式由Sriram Sakthivel所说
Using Labda expression as said by Sriram Sakthivel
Control.MouseWheel += (sender, e) =>((HandledMouseEventArgs)e).Handled = true;
这篇关于c#在Trackbar上禁用ScrollWheel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文