I have a WinForm app with a WebBrowser control on it. I create HTML programmatically. How do I use images from the project's resources inside the HTML?
Visual Basic 2010 Express.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.DocumentText = "<html><body style='background-image:url(???);background-color:#DDEEFF'>Some text.</body></html>"
End Sub
End Class
I've had a similar problem. Basically, the WebBrowser
control doesn't work well when you set DocumentText
directly.
The solution I came up with is to implement a tiny HTTP server in your app and point the WebBrowser
control to that url.
You then have complete control over all the content.
I wrote an article about it here: WebBrowserEx: WinForms WebBrowser + HTTP Server