日期:2014-05-18  浏览次数:20849 次

请问实现textBox始终保持100行数据的方法。
请问实现textBox始终保持100行数据的方法。(数据超过100行就删除100行以后的数据。)

C# code


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行以后的数据。
        }




------解决方案--------------------
while(i>100)
{
removeat(100);
}
------解决方案--------------------
C# code
int limitLineCount = 2;
                if (textBox1.Lines.Count() > limitLineCount)
                {
                    this.textBox1.Text = string.Join("\r\n", this.textBox1.Lines.Take(limitLineCount));
                }

------解决方案--------------------
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编译器的?