faster than: richTextBox1.Select(78,65);richTextBox1.SelectionColor= Color.Red;
-
Is there a faster way to give a specific color in a richTextBox?
void makeThisRed(int start, int length) { richTextBox1.Select(start,length); richTextBox1.SelectionColor= Color.Red; }
Nope. That's the fastest way to do it... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Nope. That's the fastest way to do it... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
It can't be done using pointers... All RTF formatting is done in-line with the text, kind of like HTML tags. In order for you to change a section of text to a different format, the RTF stream holding all the text and formating information must be rewritten. This means copying everything from the beginning of the RTF stream to the point where you are making your changes, appending the new formatting codes to the copy, append the segment of text you're changing, appending any closing formatting codes that are required, then, finally, appending the remaining original RTF stream. You can't do it using pointers because you have to rewrite the entire RTF stream anyway so it's in one contiguous stream of data. It sounds like, because of performance considerations, that an RTF box wasn't a good choice to fulfill your requirements. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Is there a faster way to give a specific color in a richTextBox?
void makeThisRed(int start, int length) { richTextBox1.Select(start,length); richTextBox1.SelectionColor= Color.Red; }
If you want faster RichTextBox coloring, set the color as your append the text. ie
rtb.SelectionColor = COlor.Magenta;
rtb.AppendText("Barney");
rtb.SelectionColor = Color.Black;In the end it will still be slow as #$%#. If you want something fast, you will need to write your own editor (like I did). xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
-
It can't be done using pointers... All RTF formatting is done in-line with the text, kind of like HTML tags. In order for you to change a section of text to a different format, the RTF stream holding all the text and formating information must be rewritten. This means copying everything from the beginning of the RTF stream to the point where you are making your changes, appending the new formatting codes to the copy, append the segment of text you're changing, appending any closing formatting codes that are required, then, finally, appending the remaining original RTF stream. You can't do it using pointers because you have to rewrite the entire RTF stream anyway so it's in one contiguous stream of data. It sounds like, because of performance considerations, that an RTF box wasn't a good choice to fulfill your requirements. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
I think we need a sticky post. DONT USE RICHTEXTBOX FOR SYNTAX COLORING! :laugh: xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots