Re: Read text file to Temp file and apply formating and color chan
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Mon, 20 Aug 2007 20:16:19 -0700
Brian Cook wrote:
Bummer, I was hoping that I could do it outside of the RTB in order to speed the formatting process up.
I'm not sure why you think file i/o would be faster than doing things in memory. If you can explain what it is about using the RichTextBox you think you can actually speed up, that might help in providing you an answer more closely suited to your needs.
Only other item I need to finish this tool is that when I apply the formatting and color it scrolls down to the bottom of the file as it applies, and does not put the RichTextBox up to the first line after it is done.
What would you recommend?
Well, it seems to me that for initializing the control from an existing file, you should just create an RTF string, and use the RichTextBox.Rtf property to initialize the textbox. I cannot imagine that there would be a faster way to initialize the RichTextBox. Certainly I don't believe that doing file i/o is going to speed things up.
If for some reason you feel you cannot just create an RTF string and must instead initialize the text and then format it in place, and you are concerned that formatting the text after it's added to the RichTextBox is causing a performance problem due to on-screen updating, one thing you might try doing is hiding the control while you do the update. This would work best if the control can simply start out hidden and not be shown until it's initialized.
An alternative (read, "hack" :) ) would be to use DrawToBitmap() to create a bitmap image of the control, place that in the UI instead of the RichTextBox until it's finally initialized, and then go ahead and show the RichTextBox.
As far as positioning the control at the first line of text, you should be able to get that to happen using these lines of code:
richTextBox1.Select(0, 0);
richTextBox1.ScrollToCaret();
Hope that helps.
Pete
.
- Follow-Ups:
- Re: Read text file to Temp file and apply formating and color chan
- From: Brian Cook
- Re: Read text file to Temp file and apply formating and color chan
- References:
- Re: Read text file to Temp file and apply formating and color changes
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Read text file to Temp file and apply formating and color changes
- Prev by Date: need help with ObjectDataSource
- Next by Date: Getting the "name" of an indexed item
- Previous by thread: Re: Read text file to Temp file and apply formating and color changes
- Next by thread: Re: Read text file to Temp file and apply formating and color chan
- Index(es):
Relevant Pages
|