[英]vb.net how to add and load an html file from resource into webbrowser control
I have a webbrowser
control on form2
, and the things I'd like to do are: 我在
form2
上有一个webbrowser
控件,我想做的事情是:
webbrowser
control when an if-condition is true
, and make it visible in the webbrowser
? true
,如何将其从资源加载到webbrowser
控件,并使其在webbrowser
可见? For example: 例如:
If dttest.Rows(0).Item(0).ToString = TextBox1.Text Then
webbrowser.navigate(resources and the html name page)
End If
I've already tried the webbrowser.navigate
but I want to load the HTML page. 我已经尝试过
webbrowser.navigate
但是我想加载HTML页面。
This work's for me and is tried and tested... I left the If
condition out as it's not pertinent of what you are trying to accomplish. 这项工作适合我,并且已经过尝试和测试……我将
If
条件排除在外,因为它与您要完成的目标无关。 Also no need to call Navigate
as when you set the Uri
it should load the document. 另外,也无需调用
Navigate
因为在设置Uri
它将加载文档。
Dim filename As String = "test.html"
With Me.WebBrowser1 'Change name to reflect your name
.ScriptErrorsSuppressed = True 'I was getting script errors from site
.Url = New Uri(String.Format("file:///{0}{1}{2}/", System.IO.Directory.GetCurrentDirectory(), "/Resources/", filename))
End With
Note 注意
If the Copy to Output Directory
is not set to Copy Always
for your html
file (file's) you need to make that change. 如果您的
html
文件(文件)的“ Copy to Output Directory
未设置为Copy Always
,则需要进行更改。 You can right click on the html
file and select properties. 您可以右键单击
html
文件并选择属性。 Change that property as needed. 根据需要更改该属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.