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..
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;
}
Using anonymous method
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..
Edit: Using Labda expression as said by Sriram Sakthivel
Control.MouseWheel += (sender, e) =>((HandledMouseEventArgs)e).Handled = true;