richtextbox

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

冷暖自知 提交于 2019-12-17 02:51:45
问题 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

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

落花浮王杯 提交于 2019-12-17 02:51:27
问题 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

Creating a find dialog

跟風遠走 提交于 2019-12-14 03:15:58
问题 So for this assignment in class I'm making a richtextbox editor in C# winforms, in this assignment I have to include a find function, but I can't seem to get the hang of it EDIT: it closes every time I click the search button, but that's not what I want, I want it to close when the user closes the actual dialog via the X in the top right, the search button should just highlight the found string by using the .Find() method Here's my code up until now: private void zoekenToolStripMenuItem_Click

Insert white space of arbitrary width to FlowDocument

送分小仙女□ 提交于 2019-12-14 03:14:19
问题 Is there a way to insert white space of given width to FlowDocument as Inline ? So that I can 'indent' some other Inline s as I want. If it was possible to place some inline on some x-offset in the line that would also solve the problem. NOTE: the purpose of this would be solving partial problem of the problem described in this question. 回答1: You could use the container classes, e.g.: <RichTextBox> <FlowDocument> <Paragraph> <InlineUIContainer> <FrameworkElement Width="200"/> <

Set/Unset Italic in RichTextBox

只谈情不闲聊 提交于 2019-12-14 02:28:24
问题 I have a RTF box in my C# WinForms app. Setting basic styles is fairly simple but when I try to unset the Italic style I lose all other applied styles to the selection font. if (rtf.SelectionFont.Style.HasFlag(FontStyle.Italic)) { rtf.SelectionFont = new Font(rtf.SelectionFont.FontFamily, rtf.SelectionFont.Size, rtf.SelectionFont.Style | FontStyle.Regular); } else { rtf.SelectionFont = new Font(rtf.SelectionFont.FontFamily, rtf.SelectionFont.Size, rtf.SelectionFont.Style | FontStyle.Italic);

Using Regex and updating text in richtextbox wpf c#

白昼怎懂夜的黑 提交于 2019-12-13 19:32:11
问题 I have here my piece of code: mainWindow.Dispatcher.Invoke(new Action(() => mainWindow.richtextbox2.Document.Blocks.Add(new Paragraph(new Run("Hello"))))); string myText = new TextRange(mainWindow.richtextbox2.Document.ContentStart, mainWindow.richtextbox2.Document.ContentEnd).Text; //replace two or more consecutive spaces with a single space, and //replace two or more consecutive newlines with a single newline. var str = Regex.Replace(myText, @"( |\r?\n)\1+", "$1", RegexOptions.Multiline);

how to set RTF from WinForms to WPF RichTextBox

删除回忆录丶 提交于 2019-12-13 19:09:32
问题 how to set RTF from WinForms to WPF RichTextBox . (Not by TextRange.Load() ). I have a string variable which has rtf text. I want to set this variable to wpf ritch text box. 回答1: I got the solution. MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(text)); ritchTextBox.Selection.Load(stream, DataFormats.Rtf); 来源: https://stackoverflow.com/questions/3003984/how-to-set-rtf-from-winforms-to-wpf-richtextbox

RichTextBox handling with custom ScrollBar in C#

梦想的初衷 提交于 2019-12-13 18:55:42
问题 Recently I'm on a form project with custom GUI. (MetroFrameWork) It has its own TextBox component, but I prefer RichTextBox. The problem is that it uses the windows legacy scrollbar if I set it visible. I don't want to use this. Luckily framework has its own ScrollBar component with skin I want. I can set RichTextBox with NO scrollbar (ScrollBars property set to NONE) and set the independent custom scrollbar docked to right to RichTextBox. I didn't find any good solution how could I derive or

C# Bold a part of a string in a RichTextBox

心已入冬 提交于 2019-12-13 18:09:41
问题 I am trying to bold the "You >>" part of this string to be displayed in a rich text box. The following is my code for when the message send button is clicked. displayBox is where id like the string to be bold, entryBox is where the user is entering a message. private void button1_Click(object sender, EventArgs e) { listData.Add(entryBox.Text); // Remove the linebreak caused by pressing return SendKeys.Send("\b"); // Empty the array string ArrayData = ""; // Bold the You >> displayBox

WPF RichTextBox - Replace Selected Text with Custom Control

女生的网名这么多〃 提交于 2019-12-13 16:29:13
问题 Before I start hacking in a really crude solution, I thought I'd see if someone could give me a little nudge in the right direction. What I really want to do is let a user select some text in a RichTextBox, click a button, and convert that text into a custom rendered control. Convert it to a Button containing the text they had selected, for instance. 回答1: You can do this with Command and CommandParameter First, bind the button to an ICommand, like: <Button Content="Go" Command="{Binding