How can I find the screen position of the caret for a standard Winforms TextBox?
Asked
Active
Viewed 2,230 times
2 Answers
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,333
- 1
- 31
- 42
2
I have been using the TextBox.GetPositionFromCharIndex function. It gives coordinates relative to the top left of the the TextBox.
Venkat D.
- 2,919
- 33
- 40
-
The function seems to [not work sometimes](http://stackoverflow.com/q/1831219/2388257) – Hi-Angel Jul 24 '15 at 07:56