abelLazm
Postaholic
2,113 posts since Feb 2011
Reputation Points: 219
Solved Threads: 124
I think the major issue you'll have is that the hover event only occurs one time. It won't fire again until you move the mouse off the control and back on. Given that, I created a simple form with a trackbar, a label and a timer. Below is the code I added to the various events:
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication2 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void trackBar1_MouseHover(object sender, EventArgs e) {
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e) {
trackBar1.Value += 1;
if (trackBar1.Value >= trackBar1.Maximum) timer1.Enabled = false;
label1.Text = trackBar1.Value.ToString();
}
private void trackBar1_MouseLeave(object sender, EventArgs e) {
timer1.Enabled = false;
}
}
}
Most likely you'll want to use the mouse position and trackbar position to figure out which end of the trackbar the mouse is over and scroll in the direction of the mouse.
Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
If I did all the work for you, you'd have to pay me :) As I suggested, use the mouse position (get it in the timer tick event) and figure out which end of the trackbar the mouse is pointing at. You can use that to determine if you should add or subtract.
Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558