如题,怎么才能把长篇文章按页显示在richtextbox里面,点击自定义按钮进行翻页!最好有代码,是c#2.0的!因为我用的是vs2005。

解决方案 »

  1.   

    richtextbox有Lines属性,可以通过它来控制每页显示的行数,从而达到分页的效果。
      

  2.   

    已经解决,代码如下(虽然我看懂,但是问题已经解决):
            private void pageup_Click(object sender, EventArgs e)
            {
                int sindex = richTextBox1.GetCharIndexFromPosition(new Point(1, 1));
                int eindex = richTextBox1.GetCharIndexFromPosition(new Point(richTextBox1.Width - 1, richTextBox1.Height - 1));
                int line;
                if (richTextBox1.GetPositionFromCharIndex(eindex).Y < richTextBox1.Height - richTextBox1.SelectionFont.Height)
                {
                    int height = richTextBox1.Height - richTextBox1.GetPositionFromCharIndex(eindex).Y;
                    height = height / richTextBox1.SelectionFont.Height - 1;
                    line = richTextBox1.GetLineFromCharIndex(sindex) - richTextBox1.GetLineFromCharIndex(eindex) - height;
                }
                else
                {
                    line = richTextBox1.GetLineFromCharIndex(sindex) - richTextBox1.GetLineFromCharIndex(eindex);
                }
                SendMessage(this.richTextBox1.Handle, 0xB6, 0, line);        }        private void pagedownt_Click(object sender, EventArgs e)
            {
                int sindex = richTextBox1.GetCharIndexFromPosition(new Point(1, 1));
                int eindex = richTextBox1.GetCharIndexFromPosition(new Point(richTextBox1.Width - 1, richTextBox1.Height - 1));
                int lines = 0;
                if (eindex < this.richTextBox1.Text.Length - 1)
                {
                    lines = richTextBox1.GetLineFromCharIndex(eindex) - richTextBox1.GetLineFromCharIndex(sindex);
                }
                SendMessage(this.richTextBox1.Handle, 0xB6, 0, lines);        }