c#中TextBox中的行数达到一定数目时希望只显示后面固定的行数

shirlydyh 2010-12-06 01:58:16
c#中TextBox中的行数达到一定数目时希望只显示后面固定的行数
比如说 我只希望这个TextBox 中只显示后面输入的20行
多余20行后 第一行就删除了
该怎么解决
...全文
1541 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
毛线 2010-12-06
  • 打赏
  • 举报
回复
恩。。。截取字符串!
zhao_zps 2010-12-06
  • 打赏
  • 举报
回复

textBox6.Text = Failure ;
textBox6.SelectionStart = textBox6.Text.Length;
textBox6.SelectionLength = 0;
textBox6.ScrollToCaret();
shirlydyh 2010-12-06
  • 打赏
  • 举报
回复
上面 那个方法我试了 没反应
shirlydyh 2010-12-06
  • 打赏
  • 举报
回复
if(this.textBox1.Lines.Length>20)
{
string[] newlines = new string[20];
this.textBox1.Lines = Array.Copy(this.textBox1.Lines, this.textBox1.Lines.Length - 20, newlines, 0, 20);
}



这个Array的copy方法返回值是void啊
ZengHD 2010-12-06
  • 打赏
  • 举报
回复
加个滚动条自动滚动底下不行吗?
Return门徒 2010-12-06
  • 打赏
  • 举报
回复
截取字符串,在给TextBox赋值啊

要截取多长,可以自己算啊,一行多少个字符,20行是多少个字符
sprc_lcl 2010-12-06
  • 打赏
  • 举报
回复 1
sorry

if(this.textBox1.Lines.Length>20)
{
string[] newlines = new string[20];
Array.Copy(this.textBox1.Lines, this.textBox1.Lines.Length - 20, newlines, 0, 20);
this.textBox1.Lines = newlines;
}
sprc_lcl 2010-12-06
  • 打赏
  • 举报
回复
            if(this.textBox1.Lines.Length>20)
{
string[] newlines = new string[20];
this.textBox1.Lines = Array.Copy(this.textBox1.Lines, this.textBox1.Lines.Length - 20, newlines, 0, 20);
}
nbgcqlk 2010-12-06
  • 打赏
  • 举报
回复
估计只能通过JS来解决了...

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧