Reputation: 2037
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..
Upvotes: 2
Views: 2357
Reputation: 2037
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;
Upvotes: 2