Reputation: 55
I am very new to vb but i will try to explain my situation.
I have a button that loads an xml file into a richtextbox using the openfiledialog. I then use the XmlTextReader to format the xml for easy reading (e.g. tag names and attributes appear in different colors).
All of the above works great! What i need to know is how to view the richtextbox.text in the webbrowser when the textchanges in the richtextbox. This is my code so far:
Private Sub RichTextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Dim txtHTML As String = RichTextBox1.Text
'option 1 this works with transformation but is loaded from saved file e.g. C:\file.xml
WebBrowser1.Navigate(TextBox1.Text)
'option 2 this works without transformation
WebBrowser1.DocumentText = txtHTML
End Sub
Currently i can load the xml into the webbrowser using the webbrowser.navigate but this only loads the file from the drive (see option 1 above). I can also load the webbroswer using the webbrowser.documenttext but this does not perform the xslt transformation that i require (see option 2 above).
Does anyone know how to load the richtextbox.text into the webbroswer as xml?
Upvotes: 0
Views: 497
Reputation: 51
This should do the trick.
Private Sub RichTextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Dim txtHTML As String = RichTextBox1.Text
txtHTML.Text = WebBrowser1.DocumentText
End Sub
Upvotes: 1