1. 程式人生 > >限制RichTextBox的行數方法

限制RichTextBox的行數方法

主要程式碼:

            this.richTextBox_query_txt.AppendText("" + r.Next(100000, 999999999) + "\n");

            int maxLinds = 3;

            if (this.richTextBox_query_txt.Lines.Length > maxLinds)
            {
                int moreLines = this.richTextBox_query_txt.Lines.Length - maxLinds;
                string[] lines = this.richTextBox_query_txt.Lines;
                Array.Copy(lines, moreLines, lines, 0, maxLinds);
                Array.Resize(ref lines, maxLinds);
                this.richTextBox_query_txt.Lines = lines;
            }