get point from onclick event
-
Hello, How do you get the actual point where the mouse clicked on a form during an onclick event. Here is what I have so far, but it doesn't work...
private void split_Panel2_Click(object sender, EventArgs e) { Point clickPnt = new Point(); clickPnt = (Point)sender; }
Thanks for your help! RC -
Hello, How do you get the actual point where the mouse clicked on a form during an onclick event. Here is what I have so far, but it doesn't work...
private void split_Panel2_Click(object sender, EventArgs e) { Point clickPnt = new Point(); clickPnt = (Point)sender; }
Thanks for your help! RCHandle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);
-
Handle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);
-
Handle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);
Josh Smith wrote:
Handle the MouseDown event and cache a Point variable which you can use in the Click handler.
In the Click event handler you can also use the static property
Control.MousePosition
. Much easier :). Alternatively, controls also have a MouseClick event which gives you the position of the mouse during the click in de event handler argument. -
Josh Smith wrote:
Handle the MouseDown event and cache a Point variable which you can use in the Click handler.
In the Click event handler you can also use the static property
Control.MousePosition
. Much easier :). Alternatively, controls also have a MouseClick event which gives you the position of the mouse during the click in de event handler argument.I was under the impression that he wanted to know where the mouse cursor was when the click process began (i.e. when the button was depressed). Checking Control.MousePosition is good if he wants to know the cursor position after the mouse button is released (MouseDown + MouseUp = Click). I suppose he didn't state either one specifically. Cheers, Josh