Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
I have a winform that basically contains a textbox containing html code, and a webbrowser control that renders that code and shows the result.

That works like a charm. But now I would like to let the user click or highlight some text in the webbrowser control and then in code highlight the code that generated said text in the html textbox.

How would you go about doing that? Obviously line numbers are useless in this case, and you can go by the text itself either, because the same text COULD be present more than one time, both in the code and the rendered text...

I really have no idea where to start and what to Google. Any ideas?
Posted
Comments
[no name] 5-Mar-15 10:19am    
I haven't worked with the webbrowser control yet. But I could imagine that the standard webbrowser control is simply not up to the task. Whatever the concrete solution could be, the html-rendering control needs to "map" the text selection to the html source and offer that info via some public member and I would be surprised if the standard webbrowser control offered that functionality. You might take a look at alternatives for the standard webbrowser control. Maybe some offers this or you can "hack" it into it.
http://www.codeproject.com/Articles/32376/A-Professional-HTML-Renderer-You-Will-Use
https://github.com/cefsharp/CefSharp
..etc..
Johnny J. 5-Mar-15 10:31am    
I'm inclined to agree with you, but at the same time: AFAIK, the webbrowser control offered in .NET is merely a .NET wrapper around the COM browser component that is used in IE...

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