读书人

请教实现textBox始终保持100行数据的方

发布时间: 2012-09-03 09:48:39 作者: rapoo

请问实现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编译器的?

读书人网 >C#

热点推荐