如何导入HTML文件以在VB.NET WebBrowser中显示

时间:2019-01-27 05:27:50

标签: vb.net

到目前为止,我是从OpenDialog教程和HTML编辑器/编写器教程中拼凑而成的,但是我今天才选择此内容,是为了完成此特定操作,因此我对VB和一般软件开发的先验知识非常低。 :P

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1 Click

   OpenFileDialog1.ShowDialog()
   If OpenFileDialog1.FileName > "" Then
   WebBrowser1.DocumentText = 

End sub

1 个答案:

答案 0 :(得分:0)

使用WebBrowser Control的URL属性,也始终使用过滤器仅选择所需的格式

 Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click

            OpenFileDialog1.Filter = "Html or Pdf-Files(*.html; *.pdf))|*.html;*.pdf"
            If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Dim cfilenam As String = OpenFileDialog1.FileName()
                If cfilenam.Trim().Length > 0 Then
                    Me.WebBrowser1.Url = New Uri(cfilenam)
                    Me.WebBrowser1.Refresh()
                End If
            End If

        End Sub