winforms html 编辑器 [英] winforms html editor
问题描述
任何人都知道一个很好的免费的 .NET 的 winforms html 编辑器.理想情况下,我想要 html 和预览模式以及导出到 pdf、word doc 或类似文件的可能性.
Anyone know of a good free winforms html editor for .NET. Ideally I would like html and preview modes along with the possibility of exporting to a pdf, word doc or similar.
虽然我可以从 html 输出中创建自己的导出.
Although the export I could probably create myself from the html output.
另一个不错的功能是从 word 中粘贴,它可以删除您通常最终得到的所有额外标签,但同样,没有必需标签也很好.
Another nice feature would be a paste from word that removes all the extra tags you usually end up with but again it's a nice to have not a required.
推荐答案
您可以使用 WebBrowser 控件处于设计模式,第二个 WebBrowser
控件设置为视图模式.
You can use the WebBrowser control in design mode with a second WebBrowser
control set in view mode.
为了将 WebBrowser
控件置于设计模式,您可以使用以下代码.
In order to put the WebBrowser
control in design mode, you can use the following code.
此代码是我们一款软件产品的所见即所得编辑器的超级精简版.
This code is a super stripped down version of a WYSIWYG editor for one of our software products.
只需创建一个新表单,在其上放置一个 WebBrowser
控件,然后将其放入 Form.Load:
Simply create a new Form, drop a WebBrowser
control on it, and put this in the Form.Load:
Me.WebBrowser1.Navigate("")
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
这篇关于winforms html 编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!