在 Windows 窗体上显示 HTML 内容的最佳方式是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/465258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:03:14  来源:igfitidea点击:

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

htmlvb.netwebbrowser-control

提问by user57175

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

我想在我的应用程序中最好在 Web 浏览器控件中显示 HTML 格式的内容。

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

我可以先创建一个 HTML 文档,然后将它加载到 Web 浏览器控件中,但这太笨拙了。

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

有什么方法可以将包含 HTML 代码的字符串直接加载到 Web 浏览器中?

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

Expected output: HelloWorld

预期输出:HelloWorld

I'm using Visual Basic 9 (VS2008).

我正在使用 Visual Basic 9 (VS2008)。

回答by JaredPar

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

您可以通过将WebBrowser控件拖到您的应用程序上,然后添加以下代码来完成此操作:

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

回答by AnthonyWJones

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

您可以在 Web 浏览器控件中打开文档对象,然后:-

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