Hi guys
My first post , finding c# interesting but stuck somehow

The problem is simple and straightforward

I am trying to just change value of trackbar on mousehover but am not able to

I am able to add user defined functions to trackbar1.mousehover but not able to call the orignal trackbar1.scroll

what i understand is events like trackbar1.scroll "OCCURS" but dont know how to call them by emulating events

I dont think I need to paste some code here but if you want i shall post the things i was trying to do but it was not much avail

Hope you understand my question
And yes i am a newbie to c#

have you check this site

i went through your link but they provide explanations for standard trackbar
i wish to raise default events programatically

anyone please provide soln or guide me in how to do this......

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.

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.

Thank you for your reply
You really gave me a direction of moving
But the problem is half solved as you provided a way of increasing value at tick, but not decreasing when i moved, Thanks for a soln, man

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.