Best Way to Render HTML in WinForms application?
Solution 1
Stayed with the built-in WebBrowser. The HtmlRenderer from the other answer is great, but renders an image.
Solution 2
For managed HTML renderer see HtmlRenderer on GitHub.
Michael Stum
The same thing we do every night, Pinky. Try to take over the world! Full-Stack Developer on Stack Overflow Enterprise, working to make our little corner of the Internet better for all of us.
Updated on August 22, 2020Comments
-
Michael Stum over 3 years
I have a WinForms application, running on .net 3.5. This Application generates HTML on the fly, which includes the complete document, and also an inline-CSS-Stylesheet (inside the head element).
I am using the WebBrowser control and setting browser.DocumentText to my generated HTML, but that does not seem to properly apply styles on the body element (I've set background-color to #000000 in the CSS, but the background is still white).
I wonder if a) there are some alternatives to render relatively simple HTML in C# (i.e. a completely managed HTML renderer) or b) what would be the best way to render HTML using the WebBrowser control, including correct handling of inline-css and without using a temporary file on the hard drive.
Edit: The CSS-not-applying issue was a separate problem. I've put my actual CSS in a CDATA block, which seems to cause it not to apply correctly. That is now fixed, but the question itself still stands.
-
Michael Stum almost 15 yearsI don't think that those will do be any good - to my understanding, they create HTML from a template. I am looking for something that renders HTML on screen, aka. a Browser.
-
Michael Stum almost 15 yearsNow that looks sexy, going to give it a try.
-
Arthur over 11 yearsThe HtmlRenderer has been updated since and now has full support for text selection, copy-paste, etc. FYI.
-
RoadBump about 11 yearsThere is a newer version at CodePlex and it seems that development moved to there. A great component really.
-
Mark Lakata about 11 yearsThis is superior to the internal WebBrowser, which has additional COM overhead and doesn't play well with the thread apartment model [Read: I could not get WebBrowser to work when it is launched from a BackgroundWorker thread]. And the component is only 200K!
-
SubqueryCrunch over 5 yearsI tried adding the WinForms nuget package but when i add the Html panel to a form visual studio crashes ..