Results 1 to 7 of 7

Thread: What to do if RichTextBox is not fast enough?

  1. #1

    Thread Starter
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Question What to do if RichTextBox is not fast enough?

    Hello, I have a problem.
    What I need is to highlight multiple matches within some portion of text as the user types a search pattern. Right now I'm using a RichTextBox to highlight text. The highlighting takes place if a user changes the search pattern and naturally it happens with each key press. It works, but I'm experiencing a performance issues. If the text is large enough the highlighting takes too long (up to several seconds).
    Facing that I tried to launch the highlighting procedure in a different thread aborting it and launching it again if the search pattern was changed during the highlighting but still I'm not satisfied with performance.
    Now I'm asking if there some other control I could use to speed up the process?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: What to do if RichTextBox is not fast enough?

    There's a submission in the CodeBank on high-speed syntax highlighting that I would assume would be relevant. I believe it was posted by Icyculur.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: What to do if RichTextBox is not fast enough?

    In the past I have searched far and wide for a decent syntax highlighting RichTextBox, but I concluded that they don't exist. The RichTextBox is simply not fast enough with its Highlighting because you always have to resort to selecting a piece of text, and then changing the Selected____ property. It's fine for small texts, but anything over a few 100 lines (or even less usually) results in horrible lag.

    There are much better syntax highlighting controls available, but as far as I know none of them are free. Names that come to mind are 'ActiPro' and 'Quantum Whale' (those are two companies that make them I believe). If this project is not for some company then I doubt you'd want to buy them though.

  4. #4

    Thread Starter
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: What to do if RichTextBox is not fast enough?

    Quote Originally Posted by jmcilhinney View Post
    There's a submission in the CodeBank on high-speed syntax highlighting that I would assume would be relevant. I believe it was posted by Icyculur.
    I looked at the code and the only 'new feature' I saw was the 'lockwindowupdate' call when changing the .SelectionColor.
    I'll try that but I doubt it will make any major performance improvement.
    The problem is that those 2 seconds the Icyculyr writes about is damn too slow for me.

    Well, if this won't help I'm going to investigate the possibility of buying some third-party control.

    By the way, would editing raw rtf codes make any difference? I've tried that before but either I was missing something or doing something wrong because my richtextbox did not respond to any changes I was making.

  5. #5
    Addicted Member DramaQueen's Avatar
    Join Date
    Mar 2010
    Posts
    187

    Re: What to do if RichTextBox is not fast enough?

    If you find a solution be sure to post it here, I've also tried adding syntax highlighting to .net always having to resort to lower level languages in the end. The controls are just too slow. Never had that problem with VB6 when I used it.

  6. #6

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: What to do if RichTextBox is not fast enough?

    I think HTML with Regular Expressions should make a good combination. Never tried though.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width