【问题标题】:Updating webbrowser content with SVG使用 SVG 更新网络浏览器内容
【发布时间】:2018-03-20 14:25:43
【问题描述】:

我正在使用 webbrowser 控件来显示在我的程序中创建并作为 XMLdocument 保存在公共变量中的 SVG 文件。现在我想编辑我的 SVG 并在 webbrowser 控件中加载新文件。

这是我正在使用的变量

Public XSchemaSVG As New XmlDocument

当我填充它并将其加载到我的网络浏览器中时,一切正常,然后当我想要更新版本时,我使用以下代码重新加载 SVG

  Public Sub DrawSVGinWebBrowserControl()

    Dim text As String = XSchemaSVG.InnerXml
    WebBrowser1.DocumentText = "<!DOCTYPE HTML><html><head><meta http-equiv=""x-ua-compatible"" content=""IE=11""><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""><title>SVG overzicht</title> </head><body>" & text & "</body></html>"

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    'Clear XSchemaSVG
    XSchemaSVG.RemoveAll()
    'Draw new SVG in XSchemaSVG
    DrawOverzichtSVG()
    'load new SVG in webbrowser control 
    DrawSVGinWebBrowserControl()

End Sub

但是浏览器控件中的图片并没有改变。我认为这与我清除 XMLdocument 的方式或我在 webbrowser 控件中加载它的方式有关,任何人都可以在这里帮助我并告诉我我做错了什么吗?以及如何解决?

编辑:所以我检查并确认我的 XMLdocument 正在更新。所以问题在于重新加载 webbrowser 控件。

【问题讨论】:

    标签: xml vb.net svg webbrowser-control


    【解决方案1】:

    我通过在 DrawSVGinwebbrowser 子上使用以下代码解决了这个问题

      Public Sub DrawSVGinWebBrowserControl()
    
        Dim text As String = XSchemaSVG.InnerXml
        WebBrowser1.DocumentText = "0"
        WebBrowser1.Document.OpenNew(True)
        WebBrowser1.Document.Write("<!DOCTYPE HTML><html><head><meta http-equiv=""x-ua-compatible"" content=""IE=11""><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""><title>SVG overzicht</title> </head><body>" & text & "</body></html>")
        WebBrowser1.Refresh()
    
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2013-01-06
      • 2014-08-10
      • 1970-01-01
      • 2012-10-30
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 2023-01-17
      • 1970-01-01
      相关资源
      最近更新 更多