WPF - Virtual Textbox to load large text file

Posted on 2011-05-11
Last Modified: 2014-07-15
Hello Experts,

I'm loading a large text file (5mb) into a richtextbox.  However it is very slow to load.  The line below is taking too long.

              TextRange range = new TextRange(PART_RichTextBox1.Document.ContentStart, PART_RichTextBox1.Document.ContentEnd);                            
range.Load(textStream, GetFileDataFormat(this.ViewModel.GetFileType()));  

How can I the improve performance?  

Question by:OFGemini
    LVL 8

    Accepted Solution

    Try using Memory-Mapped Files to avoid loading the full file at startup. Then, you can load only the text that fits in the visible area of the textbox, and do sequential access to the memory mapped file when scroll is done in the textbox.
    Hope this helps.

    Author Closing Comment

    Thanks.  I'll try to implement this

    Expert Comment

    by:sahana talanki
    Where you successful in this implementation? I have similar challenges in my application. Please help.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now