如何获得滚动位置的RichTextBox? [英] How to get scroll position for RichTextBox?

查看:170
本文介绍了如何获得滚动位置的RichTextBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#我工作,Windows窗体应用程序,并有RichTextBox的有大量文本的一个问题让滚动位置。



我使用这个代码:

 公共类点
{
公众诠释X;
公众诠释Ÿ;

公共点()
{
}

公共点(INT X,int y)对
{
本。 X = X;
this.y = Y;
}
}



的SendMessage(this.Handle ,EM_GETSCROLLPOS,0,水库)



但是,当控件包含大量文本,导致y偏移为Y的incorect因为高16位总是0。



有没有什么办法让滚动比16位大的位置?


解决方案

我认为这是对时间区分到一个答案

  GetPositionFromCharIndex(0)$ b $此b  




指定字符
指数


这将得到补偿的字符相对于对照


的,

I'm working in C#, Windows Forms application, and have a problem getting scroll position for RichTextBox with large amount of text.

I'm using this code:

  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)

But, when control contains large amount of text, resulting y offset is incorect because upper 16 bits of Y are always 0.

Is there any way to get scroll position larger than 16 bits?

解决方案

I thought it was about time to case this into an answer

GetPositionFromCharIndex(0)

Retrieves the location within the control at the specified character index

This will get the offset, of the character relative the the control

这篇关于如何获得滚动位置的RichTextBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆