Vb.net 保持WebBrowser';在进入设计模式时显示的内容

Vb.net 保持WebBrowser';在进入设计模式时显示的内容,vb.net,webbrowser-control,mshtml,Vb.net,Webbrowser Control,Mshtml,我有一个WebBrowser扩展类,它有一个名为.DomDesignMode的布尔属性,用于设置DomDocument是否处于设计模式 但是,当我将此属性设置为true时,浏览器将清除通过设置.DocumentText属性加载的所有以前的内容 有没有办法让它进入设计模式,并且仍然保留以前的HTML内容?谢谢 Imports System.Windows.Forms Imports mshtml Public Class WebBrowserEx Inherits WebBrowser

我有一个WebBrowser扩展类,它有一个名为
.DomDesignMode
的布尔属性,用于设置DomDocument是否处于设计模式

但是,当我将此属性设置为true时,浏览器将清除通过设置
.DocumentText
属性加载的所有以前的内容

有没有办法让它进入设计模式,并且仍然保留以前的HTML内容?谢谢

Imports System.Windows.Forms
Imports mshtml

Public Class WebBrowserEx
    Inherits WebBrowser

    Private ReadOnly Property DomDocument As mshtml.IHTMLDocument2
        Get
            If Document IsNot Nothing Then
                Return Document.DomDocument
            Else
                Return Nothing
            End If
        End Get
    End Property

    Public Property DomDesignMode As Boolean
        Get
            If DomDocument IsNot Nothing Then
                Return String.Equals(DomDocument.designMode, "on", StringComparison.InvariantCultureIgnoreCase)
            Else
                Return False
            End If
        End Get
        Set(value As Boolean)
            If DomDocument IsNot Nothing Then
                DomDocument.designMode = If(value, "on", "off")
            End If
        End Set
    End Property

End Class

现在,让我们忘记
DomDocument
,这就是我们需要的:

WebBrowser1.Document.Body.SetAttribute("contentEditable", "true")
非常感谢