richtextbox

C# - Loading a large file into a WPF RichTextBox?

南笙酒味 提交于 2019-11-27 16:09:15
I need to load a ~ 10MB range text file into a WPF RichTextBox, but my current code is freezing up the UI. I tried making a background worker do the loading, but that doesnt seem to work too well either. Here's my loading code. Is there any way to improve its performance? Thanks. //works well for small files only private void LoadTextDocument(string fileName, RichTextBox rtb) { System.IO.StreamReader objReader = new StreamReader(fileName); if (File.Exists(fileName)) { rtb.AppendText(objReader.ReadToEnd()); } else rtb.AppendText("ERROR: File not found!"); objReader.Close(); } //background

RichTextBox Newline Conversion?

☆樱花仙子☆ 提交于 2019-11-27 14:24:25
I'm using a WinForms RichTextBox. It appears that when the RichTextBox is on a form, \r\n gets converted to \n . Here's a test: I have two rich text boxes. One is richTextBox1 , which is placed on the form: this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.SuspendLayout(); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(37, 12); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(100, 96); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = ""; The other is rtb , which I create on the spot. When I run this

Why isn't the richtextbox displaying this table properly?

て烟熏妆下的殇ゞ 提交于 2019-11-27 14:02:18
问题 Apparently, the RichTextBox provided by Microsoft doesn't fully support the RTF specs. For some reason, it won't permit multi-lined rows, and destroys formatting instead. Forexample, here is the RTF code to generate a table: \par \trowd\trgaph108\trleft36\trqc\trrh280\trpaddl108\trpaddr108\trpaddfl3\trpaddfr3 \cellx2000\cellx4000\cellx6000\cellx6500\cellx8500\cellx9000\cellx11000 \pard\intbl Length of Time until Replayment\cell\cell Flate Fee Percentage\cell\cell Broker and Application Fees

C# RichEditBox has extremely slow performance (4 minutes loading)

泄露秘密 提交于 2019-11-27 13:39:10
The RichEditBox control in C# (I use VS 2005) has bad performance. I load an RTF file of 2,5 MB with 45.000 colored lines of text into the control and it takes 4 minutes. I load the same RTF into the RTF control in Wordpad of Windows XP and it loads in 2 seconds. Wordpad performs 120 times faster than my application. What is the reason, and how can I fix it? I downloaded the sourcecode of Wordpad ( http://download.microsoft.com/download/4/0/9/40946FEC-EE5C-48C2-8750-B0F8DA1C99A8/MFC/ole/wordpad.zip.exe ) and it has the same worst performance (4 minutes). But this sample is an old version of

Storing data of rich text box to database with formatting

本秂侑毒 提交于 2019-11-27 10:02:34
问题 I am new at wpf and I want to store the data of the rich text box along with its formatting (Italic, colored, Bold..) into a database (Mysql). currently when i save the data, formatting is ignored. in addition, it shows all the text in the same line when i load it back to the rich text box from the database. Looking forward to your help and suggestions! public void save() { MySqlConnection conn = new MySqlConnection(connString); MySqlCommand command = conn.CreateCommand(); string richText =

How to color different words with different colors in a RichTextBox while a user is writing and raise an event when that colored text is clicked

馋奶兔 提交于 2019-11-27 09:50:32
When a user writes some words in a rich text box, if that word matches some specific word, than the color of the that word should automatically change. When the user clicks on that particular colored text, it should raise an event. 1) An User inserts some text in a RichTextBox 2) If any word entered is part of a pre-defined list of words, that word should change color (define a color related to each word. 3) When a mouse click event is generated on a colored word, an event is raised. Possible result: Define a custom EventHandler with custom EventArgs: public class WordsEventArgs : EventArgs {

Reset RTF in RichTextBox?

感情迁移 提交于 2019-11-27 08:42:34
I'm trying to "reset" the formatting in my RichTextBox (WinForms, not WPF). I was previously using richTextBox.Text = richTextBox.Text; However, that seems to have suddenly failed me. Now no matter what I set richTextBox.Text to, it retains some of the rtf formatting. I've tried richTextBox.Rtf = richTextBox.Text; However, that complains about an incorrect format. There's gotta be a better way to do this. (Of course, selecting the entire thing, then resetting the back color, fore color, and font works, but that results in a flicker as the entire thing is selected then deselected, plus it's

How to save drew Graphics of “Paint()” into image using c#?

让人想犯罪 __ 提交于 2019-11-27 08:38:34
问题 I actually wanted to Convert RTF into Image so after googling a lot I've got a code that does it by Paint() Event of Picturebox1 and it works perfectly : private void pictureBox1_Paint(object sender, PaintEventArgs e) { e.Graphics.Clear(richTextBox1.BackColor); e.Graphics.DrawRtfText(this.richTextBox1.Rtf, this.pictureBox1.ClientRectangle); base.OnPaint(e); // below code just create an empty image file Bitmap newBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); e.Graphics.DrawImage

how to add a character at the beginning of each line in Richtextbox

╄→尐↘猪︶ㄣ 提交于 2019-11-27 08:31:04
问题 I am doing an app that adds a certain character for each selected line if you click the button. for example "//" in each line in a Richtextbox and colored the text into red, it is like the function of comment out in visual studio i tried this but it did'nt work private void toolStripButton1_Click(object sender, EventArgs e) { int firstCharPosition = richTextBox1.GetFirstCharIndexOfCurrentLine(); int lineNumber = richTextBox1.GetLineFromCharIndex(firstCharPosition); int lastCharPosition =

Add clickable hyperlinks to a RichTextBox without new paragraph

☆樱花仙子☆ 提交于 2019-11-27 06:31:11
问题 Is it possible to dynamically add hyperlinks without creating new paragraphs like in this question Dynamically adding hyperlinks to a RichTextBox? I want something like "Please visit http://www.google.com. Thank you!" not "Please visit http://www.google.com .Thank you!". Also RichTextBox must be readonly, user cannot type in it. It's something like log, all I need is to periodically add some text which sometimes contains URLs. 回答1: OK, looks like here is what I need (thanks @Blam and @PaulN