Adding a search box to a windows forms web browser control that highlights text
Posted
by evan
on Stack Overflow
See other posts from Stack Overflow
or by evan
Published on 2010-06-09T22:00:01Z
Indexed on
2010/06/09
22:02 UTC
Read the original article
Hit count: 254
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!
© Stack Overflow or respective owner