Re: Read text file to Temp file and apply formating and color chan



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
.



Relevant Pages

  • Re: Read text file to Temp file and apply formating and color chan
    ... If you can explain what it is about using the RichTextBox you ... formatting and color it scrolls down to the bottom of the file as it applies, ... it seems to me that for initializing the control from an existing ... be a faster way to initialize the RichTextBox. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Rich Text/HTML Control to Use?
    ... > We want to add a text control to our VB6 app which allows fairly ... When formatting parts of the text (as opposed to the ... the SelItalic property to True and the selection will be italicized, ... The RichTextBox works with, uh, RichText format. ...
    (microsoft.public.vb.general.discussion)
  • Re: RichTextBox text on MDI Parent form Undo Redo etc
    ... the richtextbox, will try the undo method from the child form. ... controls on the form, the child form contains the tab control and this ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: using EM_GETRECT vs. using EM_GETLINECOUNT with a RichTextBox
    ... RichTextBox with both BorderStyle and Scrollbars set to none. ... public struct REQRESIZE ... public const int WM_NOTIFY = 0x4E; ... Control tb = Control.FromHandle; ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Result of RichTextBox.AppendText of too many characters?
    ... Do the oldest characters it contains start ... Neither TextBox nor RichTextBox have any sort of automatic discarding of data. ... You can probably squeeze a little more capacity out of the control by using TextBox instead. ...
    (microsoft.public.dotnet.languages.csharp)