Click here to Skip to main content
16,005,552 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello all,

How do i sense when a user stop scrolling in trackbar? I´m doing my application in windows forms in language c#.
I need answers urgently.
Please help me

Best Regards
Posted

You could use something similar to what I just found (in a quick google search!):
http://objectmix.com/javascript/352305-detecting-end-scroll.html[^]

Note: It's written for a web page scroll bar but it would be easy to implement a similar concept for a track bar. When track bar is scrolled, set scrolling to true and start timer. When timer ticks check old trackbar scroll position against current one, if they are the same, scrolling = false and stop the timer.
 
Share this answer
 
v2
Don't know of any events for it personality but as an idea of how you could implement it
I'll call your trackbar, trackbar1

1. Somewhere in your main form class declare a variable like:
int LastValue = trackbar1.Value;


2. Double click on the scroll event for the Trackbar and write:
LastValue = trackbar1.Value;


3. Double click on the MouseUp event for the scroll bar. You should add an if statement as shown below to detect if it has actually changed track bar value.
private void trackbar1_MouseUp(object sender, MouseEventArgs e)
{
  if(trackbar1.Value != LastValue)
  {
    //TODO: Add code operations here
  }
}
 
Share this answer
 
Comments
Ed Nutting 5-May-11 15:02pm    
Please note that this is garunteed not to work if people use tab to focus on the scroll bar then scroll using arrow keys or mouse wheel. Better would be to do as I suggested which was very similar to your code but use the scroll event (or is it value changed I can't remember which) which then allows for not actually clicking the scroll bar (which is very common).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900