We have a slider in our C# WinForms application. We update some other information on the UI when the Scroll
event occurs. However, when setting the Value
property, we only notice the slider changes visually and the ValueChanged
event occurs.
It works when using record/playback, but that depends on mouse coordinates.
How can I "scroll" reliably without depending on mouse coordinates?
Here's my form in its default size:
and it works with this recording:
but it stops working reliably as soon as the form is resized:
I'm looking for a method to drag the slider from value 0 to value 3, independent of the size of the slider.
I can set the value of the slider in a code module like this:
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
SliderTestRepository.Instance.Form1.TrackBar1.Value = 3;
}
but this will only change the position of the slider and not fire the scroll events.