I want to find the X/Y pixel coordinates of the current mouse cursor position in a Winforms RichTextBox in C#. How do I go about this?
Asked
Active
Viewed 1,201 times
0
-
It depends what your input and output coordinates are? If you're in a MouseMove event you'll be using coordinates relative to the RichTextBox. This might also help http://stackoverflow.com/questions/1913682/control-pointtoclient-vs-pointtoscreen – craftworkgames Dec 17 '12 at 00:02
1 Answers
0
This should work:
Point p = new Point(Cursor.Position.X, Cursor.Position.Y);
int mx = richTextBox1.PointToClient(p).X;
int my = richTextBox1.PointToClient(p).Y;

Dan W
- 3,520
- 7
- 42
- 69