简体   繁体   English

我如何在C#Windows窗体应用程序中的Webbrowser控件中显示存储的html代码,而不在硬盘上创建html文件?

[英]How can i display stored html codes in webbrowser control in C# windows form application without creating html files on hard drive?

I have a database which has stored HTML code sources for different articles which are not in similar HTML design pattern. 我有一个数据库,该数据库为不同的文章存储了HTML代码源,这些文章不是采用类似的HTML设计模式。 I want to display these codes in windows form application control eg WebBrowser control so that it can be displayed in its original HTMLdesign style as if in the browser.But i hope if this process doesn't include creating html files on hard drive to read from it and i wish if there is a way to make the WebBrowser control navigate from objects created in the memory not created on hard drive .. For example i wish if the code could be like this : 我想在Windows窗体应用程序控件(例如WebBrowser控件)中显示这些代码,以便可以像在浏览器中一样以其原始HTMLdesign样式显示。但是,我希望此过程不包括在硬盘上创建html文件以供读取它,我希望是否有一种方法可以使WebBrowser控件从内存中创建的对象导航,而不是不在硬盘驱动器上创建的对象。例如,我希望代码是否像这样:

HTMLFile myfile = new HTML File (htmlcode);
webbrowser1.Navigate(myfile);

You should be able to do this using the DocumentText property of the WebBrowser control. 您应该能够使用WebBrowser控件的DocumentText属性来执行此操作。

For example: 例如:

webBrowser1.DocumentText = "<html><body><h1>This is a test</h1></body></html>";

See this post for more info: C# WebBrowser HTML with references to scripts and images 有关更多信息,请参见此帖子: C#WebBrowser HTML,其中包含对脚本和图像的引用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM