X / Y Click coordinates on an image in a Windows Forms application (.net)

Is there any way to find out which x / y coordinates were clicked in the FORMS application?

+3
source share
3 answers

Take a look at the MouseEventArgs class . In particular, the GetPosition method . The MSDN example uses onMouseMove, but you should also do the same with onMouseClick. Or just use the MouseClick event of the form.

eg. using the MouseClick event:

In your form:

this.MouseClick += new MouseEventHandler(myForm_MouseClick);

void myForm_MouseClick(object sender, MouseEventArgs e)
{
    int myX = e.X;
    int myY = e.Y;
}
+6
source
+3

Take a look System.Windows.Forms.Control.MousePosition(static property)

+2
source

Source: https://habr.com/ru/post/1710157/


All Articles