2009-06-22 59 views

回答

7

只能与本地互操作做到这一点:GetCaretPos

[DllImport("user32.dll")] 
[return: MarshalAs(UnmanagedType.Bool)] 
static extern bool GetCaretPos(out Point lpPoint); 
+0

工作就像一个魅力。谢谢! – bbqfrito 2009-06-23 13:18:53

2

我一直在使用TextBox.GetPositionFromCharIndex功能。它给出了相对于TextBox左上角的坐标。

+0

函数似乎[有时不工作](http://stackoverflow.com/q/1831219/2388257) – 2015-07-24 07:56:22