RichTextBox very slow

K

kelvin.koogan

I'm using a RichTextBox in a protocol analyser I'm developing. However
as the amount of data gets large, e.g. 500000 lines, the control
becomes very slow.

For example if I load in a saved file it can take 30 seconds just to
transfer data from a StringBuilder to the RichTextBox, even with
updates turned off with WM_SETREDRAW.

Also I highlight a line when the users clicks on it and this can be
slow, as can be highlighting all instances of a string match.

Is there any way to make actions like adding text to a RichTextBox or
highlighted portions of text any faster?

TIA,
KK
 
H

Herfried K. Wagner [MVP]

I'm using a RichTextBox in a protocol analyser I'm developing. However
as the amount of data gets large, e.g. 500000 lines, the control
becomes very slow.

For example if I load in a saved file it can take 30 seconds just to
transfer data from a StringBuilder to the RichTextBox, even with
updates turned off with WM_SETREDRAW.

Also I highlight a line when the users clicks on it and this can be
slow, as can be highlighting all instances of a string match.

Is there any way to make actions like adding text to a RichTextBox or
highlighted portions of text any faster?

You can write the RTF code directly instead of selecting text and changing
its properties via the 'Selection*' properties. However, I wonder how a
user should be able to deal with 500,000 lines of text. Maybe you should
consider implementing a paging mechanism or something similar.
 
K

kelvin.koogan

You can write the RTF code directly instead of selecting text and changing
its properties via the 'Selection*' properties.  

I'm sorry I don't understand what you mean, could you explain a little
more please?
However, I wonder how a
user should be able to deal with 500,000 lines of text.  Maybe you should
consider implementing a paging mechanism or something similar.

I have considered this but it seems like a lot of work and my
timescales are very tight. Is there any simple way to do this?

TIA,
KK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top