首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-09-03 
请问实现textBox始终保持100行数据的方法。请问实现textBox始终保持100行数据的方法。(数据超过100行就删除1

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

热点排行