xod Posted July 19, 2017 Share Posted July 19, 2017 Is there a way to capture all the values of trackbar while sliding the scroll? Scroll and ValueChanged event are working good in moderate speed. However if I scroll the slider fast, some values are skipped. I need in particular that the zero value in the middle of trackbar to be accurately detected. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted July 19, 2017 Share Posted July 19, 2017 If it skips over zero, you can check for that. Use Math.Sign() to see if it changed from positive to negative, or vice-versa. int oldValue = trackBar1.Value; void trackBar1_Changed(object sender, EventArgs e) { if (trackBar1.Value == 0 || Math.Sign(trackBar1.Value) != Math.Sign(oldValue)) { myFunction(); } oldValue = trackBar1.Value; } 1 Quote June 9th, 2023: Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.