Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Large text in RechTextBox

Large text in RechTextBox

Scheduled Pinned Locked Moved C#
sharepointbeta-testingquestion
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yoav Ben Zvi
    wrote on last edited by
    #1

    Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

    N L L D U 6 Replies Last reply
    0
    • Y Yoav Ben Zvi

      Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Try adding the rows to a string collection. Although it's essentially what StringBuilder does it may help isolate the problem. i.e. is it StringBuilder or is it the TextBox that is causing the hangup. List<string> lines = new List<string>(); lines.Add(...) textBox.Text = string.Join("\r\n", lines.ToArray());


      only two letters away from being an asset

      1 Reply Last reply
      0
      • Y Yoav Ben Zvi

        Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Do you need to display all the 30.000 lines, or can you suffice with the first 10.000 and a small warning label that says "only showing first 10.000 items"? If the answer is "no", do your users need the ability to "edit" the text inline? If they don't, then consider using HTML for markup and showing it in a WebBrowser. ..or use a paging-pattern, where the user can view a limited amount of text on each page. Good luck :)

        I are troll :)

        1 Reply Last reply
        0
        • Y Yoav Ben Zvi

          Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, IMO TextBox and RichTextBox are not the right choice for displaying thousands of lines of text. The reason is they need all text concatenated, and any change you apply needs to create a new huge string with new mark-up commands. When text is line-oriented, hence does not need word wrapping, I tend to use a ListBox. That is a Control that holds a collection of strings, each representing one line of text. It does not mind holding millions of lines. By default a ListBox shows text in one font, one size, one style, one color; however it is rather easy to use the DrawMode.OwnerDrawn, so one can color each line individually (or do anything more fancy yourself) in the DrawItem event. Here is an example[^]. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


          1 Reply Last reply
          0
          • Y Yoav Ben Zvi

            Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            Yoav Ben Zvi wrote:

            contains about 30,000 lines

            Not something I've done, but if I were in your situation, I would consider subclassing the RichTextBox and adding some kind of virtual mode so it only has to deal with a small percentage of those lines at once - much like you can do with a ListView.

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
            Why are you using VB6? Do you hate yourself? (Christian Graus)

            1 Reply Last reply
            0
            • Y Yoav Ben Zvi

              Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

              U Offline
              U Offline
              Uwe Keim
              wrote on last edited by
              #6

              I understood that you want to have it read-only. Probably discarding the TextBox and replacing it with e.g. a ListView [^] control in virtual mode [^] or a Data grid[^] (with one column then) would be the best way to go. Or e.g. use a WebBrowser control to show the text.

              • My personal 24/7 webcam • Zeta Test - Intuitive, competitive Test Management environment for Test Plans and Test Cases. Download now! • Zeta Producer Desktop CMS - Intuitive, very easy to use. Download now!

              1 Reply Last reply
              0
              • Y Yoav Ben Zvi

                Hi, I am writing a small application that is used to investigate log files. Currently our QA teams are using TextPad for this task. My goal is to create an application that will be able to filter and search the log text for preset expressions. The size of a typical log file is 2 - 3 MB, and contains about 30,000 lines. I am using RichTextBox so I will be able to format text. I am using a StringBuilder to concatenate all the lines (note: I am using '\r\n" after each line). I then set the content of the stringBuilder to the RichTextBox: textBox.Text += sb.ToString(); This causes the application to freeze. I tried SuspendLayout / ResumeLayout but as soon as the form is displayed the application freezes. Limiting the lines to 10,000 prevents the freezing. Any ideas?

                Y Offline
                Y Offline
                Yoav Ben Zvi
                wrote on last edited by
                #7

                Thanks for the replies. I experimented with the ListView - 30,000 thousand lines with no problem. Since most users will probably apply some heavy filtering, there shouldn't be any problem. I don't even have to use virtual mode. I'll try out the datagridview to see which is easier to use.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups