Ryan,
You can simply look at the static Position class on the Cursor class in
the System.Windows.Forms namespace. This will give you the position in
screen coordinates, which you will have to convert to your application
(which can be done on any control window by calling the PointToClient method
on the control itself).
There are some issues with this, as you are polling for the coordinate
after the mouse button is pressed, in which case, you might not get an exact
coordinate (as the mouse location can move before your code is called, and
you are polling for the coordinate).
If you need the exact coordinate, handle the MouseUp event (as that is
when the click is registered) and store the coordinates of the mouse from
the MouseEventArgs that is passed in the event handler. Then, in the Click
event, you would take those stored coordinates and work with those.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Ryan" <Ry**@discussions.microsoft.comwrote in message
news:74**********************************@microsof t.com...
>I have a winform containing a scrollable panel and a groupbox inside the
panel. There is a button inside the groupbox.
When that button is clicked; how do I capture and display the X and Y
coordinates in a messagebox?