1
我正在使用C#,Windows窗体应用程序,并且在获取大量文本的RichTextBox的滚动位置时遇到问题。如何获取RichTextBox的滚动位置?
我正在使用此代码:
public class POINT
{
public int x;
public int y;
public POINT()
{
}
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
}
SendMessage(this.Handle, EM_GETSCROLLPOS, 0, res)
但是,当控制含有大量的文本,从而y偏移是incorect由于对Y的高16位始终为0。
有没有办法让滚动位置大于16位?
请看[在此](http://www.techtalkz.com/cc-sharp/68735-richtextbox-scroll-position.html#post293785) – 2012-02-28 22:10:59
改为使用GetCharIndexFromPosition()。 GetLineFromCharIndex()将转换为行号。 – 2012-02-29 03:00:45
感谢您的重播。 @HansPassant - 我通过GetPositionFromCharIndex获取位置。即,该函数返回相对于控件视图的位置,所以GetPositionFromCharIndex(0)返回控件的精确滚动位置。 – tlombarovic 2012-02-29 14:17:51