问题描述
在.NET WebBrowser控件,我可以看到加载页面,它是设置URL属性的唯一途径。但我想,而不是给它一些HTML code,我已经在内存中,而不先写出来给一个文件。有没有办法做到这一点?还是有什么管制,将做到这一点?
On the .Net WebBrowser control the only way I can see to load a page to it is to set the URL property. But I would like to instead give it some HTML code that I already have in memory without writing it out to a file first. Is there any way to do this? Or are there any controls that will do this?
推荐答案
您想DocumentText属性:
You want the DocumentText Property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documenttext.aspx
从<一个href="http://www.$c$cguru.com/forum/showpost.php?p=1691329&postcount=9">http://www.$c$cguru.com/forum/showpost.php?p=1691329&postcount=9 :你也应该提供有两件事情:
from http://www.codeguru.com/forum/showpost.php?p=1691329&postcount=9 :Also you should provide a couple things:
-
不要设置DocumentText在构造函数中。使用的Form_Load或你自己的方法。如果在构造函数中设置DocumentText,您将无法在任何地方再设置它在应用程序中。一定要检查该窗体设计器并没有设置任。
Don't set DocumentText in the constructor. Use Form_Load or your own method.If you set DocumentText in the constructor, you will not be able to set it again anywhere in the application. Be sure to check that the Form Designer hasn't set it either.
您只能每次方法调用设置DocumentText一次。这是奇怪的,最有可能的一个错误,但这是事实。例如:在一个for循环设定DocumentText将只设置适当的循环的第一次迭代。不过,您可以创建一个小的方法来设置DocumentText传入的字符串,然后在for循环调用此方法。
You can only set DocumentText once per method call. This is odd and most likely a bug, but it's true.For example: setting DocumentText in a for-loop will only set properly on the first iteration of the loop.You can however, create a small method to set DocumentText to the passed in string, then call this method in a for-loop.
这篇关于装载在内存文本WebBrowser控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!