Rob
Rob

Reputation: 421

Load RTF into Winforms Richtextbox "in stages"

I need to display a large (>8000 lines) RTF-formatted text in my Winforms RichTextBox. But while texts up to ~500 lines appear instantly in the RichTextBox, a large text like this takes a couple of minutes.

So I was thinking, is there any way to load the Richtext in smaller portions into the RichTextBox, i.e. only when the user is scrolling further down?

Unfortunately the most obvious candidate, the method appendtext() only works for plain text, not rich text. Switching to WPF is currently not an option unfortunately.

Thanks!

Upvotes: 2

Views: 180

Answers (1)

Rob
Rob

Reputation: 421

Found the answer finally: one needs to make a selection at the very end of the RTF in the Richtextbox and the paste the next portion like this: $RichTextBox1.SelectedRtf = $rtf. Loading the RTF in portions of about 600 lines, this is way faster (about 10x) than loading the whole RTF at once. Still much, much slower than loading plain text of the same size, though.

Upvotes: 1

Related Questions