Large text in RechTextBox
-
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?
-
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?
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
-
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?
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 :)
-
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?
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.
-
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?
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) -
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?
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 aWebBrowser
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!
-
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?
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.