呈现HTML的最佳控件

| 我需要在C#.NET 4.0 Winforms应用程序中呈现一些html文本(而不是带有
<html>
<body>
标记以及所有内容的html页面,仅包含
<i>
\'s和
<hr />
s之类的东西)。最好是一个类似于
Panel
的控件,您只需按
p.HTML = \"somehtml\"
就可以显示HTML。有没有人推荐过.NET HTML呈现控件的经验?我在codeproject上发现了这个,但是我对那里的东西有些警惕。     
已邀请:
为什么不使用
WebBrowser
控件。您始终可以将HTML代码段括在标准
<html/>
标记中。
string html = \"<i> some text </i>\";
webbrowser1.DocumentText = string.Format(\"<html>{0}</html>\", html);
    
你可以试试这个链接   您可以在以下位置使用WebBrowser控件   第二个WebBrowser的设计模式   控件设置为查看模式。      为了把WebBrowser控件   在设计模式下,您可以使用   以下代码。      此代码是超级精简版   所见即所得编辑器的以下版本   我们的软件产品。      只需创建一个新表单,然后删除   WebBrowser控件就可以了,把这个   在form_load
Me.WebBrowser1.Navigate(\"about:blank\")
Application.DoEvents()
Me.WebBrowser1.Document.OpenNew(False).Write(\"<html><body><div id=\"\"editable\"\">Edit this text</div></body></html>\")

\'turns off document body editing
For Each el As HtmlElement In Me.WebBrowser1.Document.All
    el.SetAttribute(\"unselectable\", \"on\")
    el.SetAttribute(\"contenteditable\", \"false\")
Next

\'turns on editable div editing
With Me.WebBrowser1.Document.Body.All(\"editable\")
    .SetAttribute(\"width\", Me.Width & \"px\")
    .SetAttribute(\"height\", \"100%\")
    .SetAttribute(\"contenteditable\", \"true\")
End With

\'turns on edit mode
Me.WebBrowser1.ActiveXInstance.Document.DesignMode = \"On\"
\'stops right click->Browse View
Me.WebBrowser1.IsWebBrowserContextMenuEnabled = False
    

要回复问题请先登录注册