小技巧textbox的行数

没什么技术含量,但如果不知道则实现起来很麻烦。

c#中textbox.lines只记录回车的数量,并不是真正的总行数,如何得到呢,请使用:

int 总行数 = this.textBox1.GetLineFromCharIndex(this.textBox1.Text.Length) + 1 ;

下面按钮,每点一下翻3行,只到最后,相当于翻页功能

     private void button1_Click(object sender, EventArgs e)
        {
            int m = this.textBox1.GetFirstCharIndexFromLine(3);
            if (m != -1)
            {
                this.textBox1.Text = this.textBox1.Text.Substring(m);
            }
        }

原文地址:https://www.cnblogs.com/81/p/7748616.html