C# winform Richtextbox 添加上千行数据卡

Scrption是一个List>型数据。当其中有2000行左右的数据时,会卡顿很久。

 foreach (List<string> block in scrption)
                    {
                        foreach (string text in block)
                        {
                            rtbContext.Text += text + "\n";
                        }
                        rtbContext.Text += "\n";
                    }

一次读取太多数据了,这是肯定的,你用分页查询

rtbContext.Text = "";
string textAll = "";
foreach (List block in scription)
{
foreach (string text in block)
{
textAll += text + "\n";
}
textAll += "\n";
}
rtbContext.Text += textAll + "\n;

改成上面这样就好了。