views:

95

answers:

1

I have a windows forms (using c#) application. It displays a webpage and has a textbox/botton combination which can be used to search for text displayed to the user. Currently I search the inner text of all elements for the text in the textbox. And then I weed out the elements that are redundant (for example a word could be in a 'p' and 'b' element where the 'b' is a child element of 'p' so the element returned should be 'b'). Finally I run the ScrollIntoView(true) method on the found element.

I'd now like to add a function that highlights the text (like if you search for a term in a real webbrowser). My first thought was to just inject html and or javascript code around the text but that seems like a messy solution.

Any ideas on how I should do this? Thanks for your help!

A: 

Here's an article that shows you how to do this.

http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/

Shawn Steward
Thanks, but that solution injects html into the page which could mess up the layout and I'm trying to avoid that route. I found a link on that page that tries to do it with javascript though and I'll take a look at it.
evan