How would I update mouse position in ToolStripStatusLabel

996 views Asked by At

Possible Duplicate:
How to track mouse X/Y position and print it to a label?

I seem to have run into a road bump with what seems to be a small problem but can't seem to find the answer. This is my first question asked here, and I apologize if I missed the solution to this question!

I have a toolStripStatusLabel that I want to have the current position of the mouse, I was able to get the coordinates doing this:

private void mouseCoordinatesToolStripStatusLabel()
{
    this.toolStripStatusLabel1.Text = MousePosition.ToString();
    this.Refresh();
}

But this has only been able to get me the mouse's position when I load and not when I move my mouse.

Any help would be appreciated, thank you!

1

There are 1 answers

4
danielQ On BEST ANSWER

This will give you the mouse cursor coordinates:

...
this.toolStripStatusLabel1.Text = Cursor.Position.X.ToString() + " - " + Cursor.Position.Y.ToString();
...

If you want to be updated on mouse move, just bind the MouseMove event from your Form and add previous code. Actually, yours is ok too, you just seem to be missing to bind the the MouseMove event.