How can I move a TrackBar in response to mouse events in C #?

This is probably the n00b request. I have a need when I want to change the value of a trackbar based on a mouse event. I did this as follows:

private void MoveTrackBarToMouseClickLocation(TrackBar a_tBar, int a_mouseX)
{
    // Jump to the clicked location

        double dblValue;
        dblValue = ((double)a_mouseX / (double)a_tBar.Width) * (a_tBar.Maximum -    a_tBar.Minimum);
        a_tBar.Value = Convert.ToInt32(dblValue);
}

This part works great. I am having problems with the scroll operation when I click the mouse. for example, If I click on the track panel and I need to say the value 50 with the mouse, I want to be able to scroll left or right (from the value = 50) while this mouse is not working.

Hope I clarified my little problem. Any help is appreciated. Thanks

+3
source share
1 answer

MouseMove , MouseDown. >

, , . , MouseDown, , . TrackBar , , .

, / MoveTrackBarToMouseClickLocation, . MouseDown , .

+2

Source: https://habr.com/ru/post/1781781/


All Articles