RE: Effective coloring in RichTextBox
- From: Jakub Cermak <JakubCermak@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 13:27:01 -0700
Making RTF code by hand appeared on my mind, but that's what I didnt want to
do.
InkEdit isn'a solution. Quote from msdn library:
This control is a superset of the RichTextBox control. It extends the
RichTextBox control with the ability to capture, recognize, and display ink.
The selection is quite fast, i commented the coloring line, and it all took
3s, which is good. I played with the messages, but as I wrote it made it
faster only a little bit more.
Any more ideas?
--
Jakub Cermak
"AMercer" wrote:
.Hello, I've RichTextBox with quite long text (thousands of lines) and I'm
doing something line syntax coloring. I set different colors to each word,
number etc. with selecting the text (Select()) and the setting
SelectionColor. But it's very slow. I even tried to send the messages
manually and avoid the calling of SelectionColor (that's the slowest thing)
but it's not much better. How to do this effectively?
I don't think there is a way to get good performance with the RichTextBox
methods. I think the reason is that every highlight operation you do results
in reconstituting the RichTextBox's .rtf field which is a very large string
if you have thousands of lines. Selecting text can also be costly if you are
using SelectionColor and/or SelectionBackColor.
To get good performance with a RichTextBox, you could build the rtb's .rtf
field (using stringbuilder) in one pass over the rtb's text looking for
things to highlight. The prerequisite is coming to terms with the MS RTF
specs and how they are used in a RichTextBox. Or you could try (trial and
error) the win32 apis and messages like EM_SETCHARFORMAT. Or maybe you could
use InkEdit which is supposed to be a superset of RichTextBox. All sound
daunting to me.
Maybe there is an alternative to RichTextBox, but I don't know what it is.
Sorry there is no good news in this post.
- Follow-Ups:
- RE: Effective coloring in RichTextBox
- From: AMercer
- RE: Effective coloring in RichTextBox
- References:
- Effective coloring in RichTextBox
- From: Jakub Cermak
- RE: Effective coloring in RichTextBox
- From: AMercer
- Effective coloring in RichTextBox
- Prev by Date: Re: 6 years later - bugfix neither found its way into 2.0 or 2.0SP1
- Next by Date: Print pdf document using PRintDocument
- Previous by thread: RE: Effective coloring in RichTextBox
- Next by thread: RE: Effective coloring in RichTextBox
- Index(es):
Relevant Pages
|