Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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.
Posted
Updated 8-Jun-11 5:42am
v2
Comments
Kschuler 8-Jun-11 12:22pm    
How are you using the string? Is it just displayed in the html? Is it in a control?
Sergey Alexandrovich Kryukov 8-Jun-11 14:13pm    
Not clear. Are you asking only about presentation of highlighted text, or you need some algorithm. Also, what's your data structures presenting your results of comparison?
--SA
MJ_ 8-Jun-11 14:21pm    
I would like to make it a control that I am going to have to call for several different paragraphs. Basically a label but with different parts highlighted in different colors. I will highlight until the strings match, then continue unhighlighted until it finds a mismatch. Then it will highlight.

Bascally highlight parts of the label based off if the strings don't match and not highlighting that parts where they do.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900