Mo-
Mo-

Reputation: 184

Huge string into a WinForm RichTextBox

I have a big string (20K lines * 100 character each).

I need to place this string into a RichTextBox (or any similar thing) of a windows forms application, currently it takes 40 second to do so, (appending the String itself takes 40 sec).

Here is a code snippet

StringBuilder sb = Very_big_String_Builder_Object;
string appendMe = sb.ToString();
uniqueOutput.SelectionStart = uniqueOutput.TextLength;
uniqueOutput.SelectedText = appendMe;

I also tried

StringBuilder sb = Very_big_String_Builder_Object;
string appendMe = sb.ToString();
uniqueOutput.Text = appendMe;

which was a little bit worst.

Is there anything within .NET (up to 4.5) that can help ?

Upvotes: 1

Views: 552

Answers (2)

rheitzman
rheitzman

Reputation: 2297

Try using a TextBox with multiline True:

txtMulti.text = Very_big_String_Builder_Object.ToString;

Upvotes: 1

user3175253
user3175253

Reputation: 598

Disabling WordWrap and DetectUrls will surely save you a couple of seconds.

Upvotes: 2

Related Questions