0

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?

Dan W
  • 3,520
  • 7
  • 42
  • 69
  • 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 Answers1

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