3

How can I find the screen position of the caret for a standard Winforms TextBox?

bbqfrito
  • 198
  • 2
  • 9

2 Answers2

8

You can do it only with native interop: GetCaretPos

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetCaretPos(out Point lpPoint);
arbiter
  • 9,447
  • 1
  • 32
  • 43
2

I have been using the TextBox.GetPositionFromCharIndex function. It gives coordinates relative to the top left of the the TextBox.

Venkat D.
  • 2,979
  • 35
  • 42