Displaying html within a windows form

GornHorse

Member
Joined
Jun 8, 2004
Messages
5
Programming Experience
5-10
Hi There,

I have looked everywhere for help on this, but with no luck, so I'm hoping the lovely people here may be able to give me some pointers.

I have some html text that I retrieve out of a database, and all I need to do is to be able to display the html formatted version of this text within my windows form somehow.

I have tried using the AxWebBrowser control, but I can't pass it my text to display.

I have also tried using the AxScriplet control, but I can't pass it my text either.

I have also tried the RichTextBox control, and it displays the text, but it doesn't display html formatted.

Please, if someone can give me some advice here, I would be much appreciated.

One thing that I don't want to do if I can help it, is that I don't want to have to save the html anywhere in order to display it - I would much prefer to be able to have it stream into a control and display in html format.


Thanks heaps,
Michelle
 

GornHorse

Member
Joined
Jun 8, 2004
Messages
5
Programming Experience
5-10
Ok, so whenever I post a question, I always find an answer just after it. For those who are interested, here's a great result.

Do the following to specify a blank url that will create a document in the AxWebBrowser1, otherwise, it will be nothing.
VB.NET:
Dim o As Object = System.Reflection.Missing.Value 
 
AxWebBrowser1.Navigate("about:blank", o, o, o, o)


Then, add the following event handler that will fire when the document is no longer nothing, but exists.


VB.NET:
Private Sub AxWebBrowser1_StatusTextChange(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEvent) Handles AxWebBrowser1.StatusTextChange
 
Dim doc As mshtml.HTMLDocument = New mshtml.HTMLDocument()
 
doc = Me.AxWebBrowser1.Document
 
doc.body.innerHTML = "<font face=""Arial"" size=""1"">" & txt & "</font>"
 
End Sub
For more information on this, go to :
http://blogs.msdn.com/kaevans/archive/2003/02/25/2936.aspx
 

vbkev

Active member
Joined
Jun 4, 2004
Messages
32
Location
Newcastle, UK
Programming Experience
5-10
Or, you could write the html to a temporary file and use the AxWebBrowser to browse to it.
 
Top Bottom