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

Hello,

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.
PatricePaquetteAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Bob LearnedConnect With a Mentor Commented:
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
http://www.vb-helper.com/howto_get_webbrowser_text.html

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 = _
        WebBrowser1.Document.ActiveElement.InnerText
    txtResult(6).Text = _
        WebBrowser1.Document.ActiveElement.OuterText
    txtResult(7).Text = _
        WebBrowser1.Document.ActiveElement.InnerHtml
    txtResult(8).Text = _
        WebBrowser1.Document.ActiveElement.OuterHtml
End Sub

Bob
0
All Courses

From novice to tech pro — start learning today.