突出显示两个段落之间的变化 [英] Highlighting changes between two paragraphs
问题描述
背景信息:(如果需要,请跳过)我创建了一个函数,该函数查找两个字符串之间最长的公共序列并保存结果.现在,我想构建一个控件,该控件以黄色突出显示添加的内容,以红色突出显示删除的内容.为此,我只将一个字符串与下一个字符串进行比较,只要我发现与下一个字符串不匹配的内容,就会突出显示.
我已经弄清楚了它是如何工作的,我只是想知道哪种最佳方式以不同的颜色突出显示段落的各个部分,同时保持与未突出显示时相同的格式.
Background info: (skip if you want) I created a function that finds the longest common sequence between two strings and saves the results. Now I want to build a control that displays what was added as highlighted in yellow and what was removed as highlighted in red. To do this I just compare one string to the next and anytime I find something that doesn''t match the next things will be highlighted.
I''ve worked out how it works, I just was wondering what the best way for highlighting parts of a paragraph in different colors while keeping the same formating as when it is not highlighted.
推荐答案
RichTextBox类...已解决问题!
C#-通过解析RTF格式(RTF)在RichTextBox中设置文本格式 [ http://msdn.microsoft.com/en-us/library/system. windows.forms.richtextbox.aspx [ ^ ]
RichTextBox Class... Problem solved!
C# - Formatting Text in a RichTextBox by Parsing the Rich Text Format (RTF)[^]
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx[^]
这篇关于突出显示两个段落之间的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!