richTextBox 我如何删除指定的行数据 ,数据我是 后来在上面显示的 如下
10 .............
9  ..................
8.....................
7..................
这样的,数据超过 3行我要把 7这行数据删除了.这个语句该怎么写.谢谢了

解决方案 »

  1.   

    代码测试过了。把richbox读到数组,然后逐个读取,重新写入richbox,大于3就不写
    string[] sptt ={ "\n" };
                string A = richTextBox1.Text.ToString();
                string[] cells = A.Split(sptt, StringSplitOptions.RemoveEmptyEntries);
                int i = 0;
                richTextBox1.Text = "";
                foreach (string tc in cells)
                {
                    i++;
                    if (i < 4)
                    {
                        
                        richTextBox1.AppendText(tc.ToString());
                        richTextBox1.AppendText("\n");
                    }
                }
      

  2.   

    string[]   sLines= richTextBox1.Lines;
    string[]  sNewLines=new   string[sLines.Length-3]; 
    Array.Copy(sLines,3,sNewLines,0,sNewLines.Length   ); 
    richTextBox1.Lines=sNewLines; var result=sLines.Skip(1);