C# .NET 4.0 Winforms アプリケーションで、いくつかの html テキスト (<html>
と<body>
タグとすべてを含む html ページではなく、いくつか<i>
の となど) をレンダリングする必要があります。<hr />
できれば、HTML を表示するPanel
だけのようなコントロールにすることをお勧めします。p.HTML = "somehtml"
推奨できる .NET HTML レンダリング コントロールを使用した経験のある人はいますか? 私はこれをcodeprojectで見つけましたが、そこにあるものには少し警戒しています.
2726 次
2 に答える
4
ビルトインWebBrowser
コントロールを使用しないのはなぜですか。HTML スニペットはいつでも標準<html/>
マークアップで囲むことができます。
string html = "<i> some text </i>";
webbrowser1.DocumentText = string.Format("<html>{0}</html>", html);
于 2011-05-26T01:06:36.960 に答える
0
この1つのリンクを試すことができます
ビュー モードで設定された 2 番目の WebBrowser コントロールを使用して、デザイン モードで WebBrowser コントロールを使用できます。
WebBrowser コントロールをデザイン モードにするには、次のコードを使用できます。
このコードは、当社のソフトウェア製品の 1 つの WYSIWYG エディターの非常に単純化されたバージョンです。
新しいフォームを作成し、そこに 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
于 2011-05-26T01:07:59.533 に答える