"Linking" the forms.WebBrowser to a forms.RichTextBox.


Is it possible to "link" a System.windows.forms.webbrowser to a System.windows.forms.richtextbox to have a similar effect as in an html editor?
The result would be that whenever someone highlights or changes a part of the html code, the equivalent in the browser would also get highlighted/changed(In real-time).

Thank you.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
It would be kind of tricky, but the HTML DOM structure has the ActiveElement property, that you can set for the WebBrowser.Document.

Simple example:

Get all text or the selected text from a WebBrowser control by using the control's methods

Private Sub Command1_Click()
    txtResult(1).Text = WebBrowser1.Document.Body.InnerText
    txtResult(2).Text = WebBrowser1.Document.Body.OuterText
    txtResult(3).Text = WebBrowser1.Document.Body.InnerHtml
    txtResult(4).Text = WebBrowser1.Document.Body.OuterHtml
    txtResult(5).Text = _
    txtResult(6).Text = _
    txtResult(7).Text = _
    txtResult(8).Text = _
End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.