ScriptUO

Casa de TrailMyx => Programming / Operating Systems => .NET Programming => Topic started by: TrailMyx on June 29, 2008, 01:23:10 AM

Title: Using RichTextBox (barf)
Post by: TrailMyx on June 29, 2008, 01:23:10 AM
If you are one of the unfortunate few who needs to use the RichTextBox for your text display project, I do feel sorry for you.  If you can get along by just using the same font/size/style, then you won't have a performance problem.  However, if you try and do much formatting of the text for coloration or style changes, you will find that this .NET control is abhorrently slow. 

Finally, for ScriptUO I had to write a set of routines to quickly context color the text.  If you use the methods included with the base class, you can expect a control containing 150K bytes, or about 5500 lines of text to take more than 4 MINUTES to color.  Yes, MINUTES. 

Since this was waaaaay too long, I found myself looking for a better way to do this, but still trying to utilize the RTB control.  I finally came up with a set of routines which I could write to the control directly with Rich Text Formatted syntax, and quickly draw the control content.  The 4 minutes was trimmed to just under 1 second.

I'm going to post the code I came up with in hopes that it'll help someone who's stuck using this control.  Ultimately I had to dump the RTB completely since there was still performance issues during editing of such large amounts of data that require constant formatting. 

So keep checking back and hopefully soon I'll have this code ready for generic deployment.

TM
Title: Re: Using RichTextBox (barf)
Post by: foobio on April 28, 2012, 05:14:15 PM
Microsoft stuff in general isn't that hot for performance.

I think the data grids in .net were coded by a room of monkeys with typewriters.  We have gone 3rd party for all UI elements.
Title: Re: Using RichTextBox (barf)
Post by: TrailMyx on April 29, 2012, 10:27:32 PM
It really is a shame that the stock .NET elements aren't really all that useful.  It's because of the lame basic implementation of most controls that I was very shy of .NET for quite some time.  Once you see how they perform in real situations, you just begin to wonder just how crappy the rest of the stuff Microsoft codes actually is.
Title: Re: Using RichTextBox (barf)
Post by: Crome969 on April 30, 2012, 12:15:22 AM