Pick up coordinates of the mouse position when clicking

0

I have to draw a line with a starting and ending point, I can do this line if I provide these coordinates through the keyboard, but I want to do this by clicking the mouse, the first would be the starting point and the second the end and the data the algorithm would plot the straight, how should I do?

It's a Windows Forms application in C #

    
asked by anonymous 24.02.2016 / 03:36

1 answer

1

If you want the coordinates according to the component clicked

Point coordenadas = control.PointToClient(Cursor.Position);

If it is according to the position on the monitor

Point coordenadas = Cursor.Position;

Point is a class which contains the properties X (horizontal position) and Y (vertical position).

    
24.02.2016 / 03:45