What is the best way to display HTML content on a Windows Form?

一曲冷凌霜 提交于 2019-12-08 14:44:06

问题


I want to display an HTML formatted content in my application preferably inside a Web Browser control.

I could create an HTML document first and then load it in the Web Browser control, but that is just too clumsy.

Is there any way I can load a string that contains HTML code directly into the Web Browser?

String = "<b>Hello</b> World"

Expected output: Hello World

I'm using Visual Basic 9 (VS2008).


回答1:


You can do this by dragging a WebBrowser control onto your application and then adding the following code:

 webBrowser1.DocumentText = "<b>Hello</b> World";



回答2:


You can open the document object in the Web Browser control then:-

document.write("<b>Hello</b> World");


来源:https://stackoverflow.com/questions/465258/what-is-the-best-way-to-display-html-content-on-a-windows-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!