簡體   English   中英

vb.net如何從資源添加html文件並將其加載到webbrowser控件中

[英]vb.net how to add and load an html file from resource into webbrowser control

我在form2上有一個webbrowser控件,我想做的事情是:

  1. 如何將HTML文件添加到資源中?
  2. 如果if-condition為true ,如何將其從資源加載到webbrowser控件,並使其在webbrowser可見?

例如:

 If dttest.Rows(0).Item(0).ToString = TextBox1.Text Then
  webbrowser.navigate(resources and the html name page)
 End If    

我已經嘗試過webbrowser.navigate但是我想加載HTML頁面。

這項工作適合我,並且已經過嘗試和測試……我將If條件排除在外,因為它與您要完成的目標無關。 另外,也無需調用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

注意

如果您的html文件(文件)的“ Copy to Output Directory未設置為Copy Always ,則需要進行更改。 您可以右鍵單擊html文件並選擇屬性。 根據需要更改該屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM