Reputation: 3
In WinForms
, I have a list with more than 10000 rows.
I have to print each row in a RichTextBox
control, but the program freezes, and takes something like 10 minutes. In order to create the list, the program takes 3 seconds.
My problem is: how can I print the result without waiting so much?
Here's the code:
for(int i=0; i < 1000; i++) {
//(...) add a row
}
foreach (string item in list)
{
richTextBox1.Text += item + "\r\n";
}
Upvotes: 0
Views: 161
Reputation: 9100
Use StringBuilder
and assign its result to the richTextBox1.Text
:
var sb = new StringBuilder();
foreach (string item in list)
{
sb.Append(item + "\r\n");
}
richTextBox1.Text += sb.ToString();
Upvotes: 3