richtextbox

How to compare two rich text box contents and highlight the characters that are changed?

浪子不回头ぞ 提交于 2019-11-26 16:31:07
Code that I used for reading the 2 richtextbox contents are as follows: richTextBox1.Text = File.ReadAllText(tfsVersionFilePath); richTextBox2.Text = File.ReadAllText(dbVersionFilePath); Now, I need to compare the two rich text box contents and highlight the characters that are changed in both richtextboxes. Purpose is to get the difference and highlight the characters as in TFS (comparing files) through c# application. Thanks. Edit: int length = (richTextBox1.Text.Length > richTextBox2.Text.Length) ? richTextBox1.Text.Length : richTextBox2.Text.Length; for (int i = 0; i < length; i++) { if

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

╄→尐↘猪︶ㄣ 提交于 2019-11-26 16:26:52
问题 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? 回答1: I downloaded the sourcecode of Wordpad (http://download.microsoft.com/download/4/0/9/40946FEC-EE5C-48C2-8750-B0F8DA1C99A8/MFC/ole

Reset RTF in RichTextBox?

瘦欲@ 提交于 2019-11-26 14:08:12
问题 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

Displaying tooltip on mouse hover of a text

倾然丶 夕夏残阳落幕 提交于 2019-11-26 12:28:29
问题 I want to display a tooltip when the mouse hovers over a link in my custom rich edit control. Consider the following text: We all sleep at night . In my case the word sleep is a link. When the user moves the mouse under the link, in this case \"sleep\", I want to display a tooltip for the link. The following came to my mind, but they are not working 1) Trapping OnMouseHover if(this.Cursor == Cursors.Hand) tooltip.Show(textbox,\"My tooltip\"); else tooltip.Hide(textbox); But this does not work

Change color of text within a WinForms RichTextBox [duplicate]

半世苍凉 提交于 2019-11-26 12:27:34
问题 This question already has answers here : Color different parts of a RichTextBox string (8 answers) Closed 3 years ago . I have a RichTextBox that I write a string to every time I click a Form button. Each string begins with the string \"Long\" or \"Short\" and ends with a newline. Each time I add a string, it appends to the bottom of the RichTextBox. I\'d like to color each line red if it beings with \"Long\" and blue if it begins with \"Short\". How can I do this? 回答1: Sure, so what you can

How can I insert an image into a RichTextBox?

情到浓时终转凉″ 提交于 2019-11-26 12:16:47
Most of the examples I see say to put it on the clipboard and use paste, but that doesn't seem to be very good because it overwrites the clipboard. I did see one method that manually put the image into the RTF using a pinvoke to convert the image to a wmf. Is this the best way? Is there any more straightforward thing I can do? The most straightforward way would be to modify the RTF code to insert the picture yourself. In RTF, a picture is defined like this: '{' \pict (brdr? & shading? & picttype & pictsize & metafileinfo?) data '}' A question mark indicates the control word is optional. "data"

Get current scroll position from rich text box control?

被刻印的时光 ゝ 提交于 2019-11-26 11:26:44
问题 I have searched the internet far and wide and seen many questions like this, but I have not seen an actual answer. I have a rich text box control with lots of text in it. It has some legal information in this control. By default the \"Accept\" button is disabled. I want to detect on the scroll event if the position of the v-scroll bar is at the bottom. If it is at the bottom, enable the button. How would I detect the current v-scroll bar position? Thank You! EDIT I am using WinForms (.Net 4.0

C#: Synchronize Scroll Position of two RichTextBoxes?

為{幸葍}努か 提交于 2019-11-26 11:24:14
问题 In my application\'s form, I have two RichTextBox objects. They will both always have the same number of lines of text. I would like to \"synchronize\" the vertical scrolling between these two, so that when the user changes the vertical scroll position on one, the other scrolls the same amount. How might I go about doing this? 回答1: I did this for a small project a while ago, and here's the simplist solution I found. Create a new control by subclassing RichTextBox: public class

How do you prevent a RichTextBox from refreshing its display?

会有一股神秘感。 提交于 2019-11-26 11:18:17
问题 I have a RichTextBox where I need to update the Text property frequently, but when I do so the RichTextBox \"blinks\" annoyingly as it refreshes all throughout a method call. I was hoping to find an easy way to temporarily suppress the screen refresh until my method is done, but the only thing I\'ve found on the web is to override the WndProc method. I\'ve employed this approach, but with some difficulty and side effects, and it makes debugging harder, too. It just seems like there\'s got to

Detecting if paste event occurred inside a rich text box

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 09:48:09
问题 Is there a way by which we can find out if a clip board paste event occurred in a rich text box? This event would be used in order to do certain stuff, with the pasted block of text. thanks Here is my code protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg == WM_PASTE) { OnPasteOccurred(); MessageBox.Show(\"Pas\"); } if (m.Msg == 0x000F) { if (PaintControl) { base.WndProc(ref m); } else { m.Result = IntPtr.Zero; } } else { base.WndProc(ref m); } } Edit I wish to