问题
Is there a way to tell what x/y coordinates were clicked in a FORMS application?
回答1:
Take a look at the MouseEventArgs class. Specifically the GetPosition method. The example on MSDN is using onMouseMove, but you should be able to do the same with onMouseClick. Or just use the MouseClick event of the form.
E.g. using the MouseClick event:
On your form:
this.MouseClick += new MouseEventHandler(myForm_MouseClick);
void myForm_MouseClick(object sender, MouseEventArgs e)
{
int myX = e.X;
int myY = e.Y;
}
回答2:
The MouseDown, MouseUp and MouseClick events all return the X and Y coordinates of the action.
回答3:
Look at System.Windows.Forms.Control.MousePosition
(static property)
来源:https://stackoverflow.com/questions/975468/x-y-coordinates-of-click-on-an-image-in-a-windows-forms-application-net