请问实现textBox始终保持100行数据的方法。(数据超过100行就删除100行以后的数据。)private void addlog(string str)
        {
            string strTxtLog = textBoxLog.Text;
            textBoxLog.Text = "[" + DateTime.Now.ToString() + "]" + str + "\r\n" + strTxtLog;
            dellog();
           
        }private void dellog()
        {
            //实现textBoxLog行数超过100行自动删除100行以后的数据。
        }

解决方案 »

  1.   

    while(i>100)
    {
        removeat(100);
    }
      

  2.   

    int limitLineCount = 2;
                    if (textBox1.Lines.Count() > limitLineCount)
                    {
                        this.textBox1.Text = string.Join("\r\n", this.textBox1.Lines.Take(limitLineCount));
                    }
      

  3.   

     int count = this.richTextBox1.Lines.Length;
                if (count > 2)
                {
                    string[] str = this.richTextBox1.Lines;
                    this.richTextBox1.Lines = new string[] { str[0], str[1] };
                }楼上this.textBox1.Lines.Take(limitLineCount) Take 函数 是 4.0编译器的?