I am using C# winforms and have a panel that scrolls that I would like to detect the coordinates of a mouse click within the panel in relation to the panel.
I am simply trying to get the coordinates and print them out for now. There is already another post about this on here but it's not letting me ask this question there so I thought I'd post another
The first line is run in another function and the function the line is adding is below that. I am getting errors that e.y and e.x are not defined. Any suggestions would be greatly appreciated.
MapPanel.Click += new System.EventHandler(OnMapClick);
void OnMapClick(object sender, EventArgs e)
{
Point scrolledPoint = new Point(e.X - MapPanel.AutoScrollPosition.X,
e.Y- MapPanel.AutoScrollPosition.Y);
Console.WriteLine(scrolledPoint.ToString());
}