将WinForms RichTextBox数据保存为HTML? [英] Save Winforms RichTextBox Data as HTML?

查看:348
本文介绍了将WinForms RichTextBox数据保存为HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将Access VBA应用程序转换为VB.NET,并且VBA应用程序中的一个文本框(格式设置为RichText)接受来自Word文档的直接粘贴,包括其格式并将其保存到Access数据库作为HTML ... HTML然后从数据库中读取并显示为它在检索时最初粘贴的内容。我现在的问题是,我可以使用Web浏览器控件来正确显示数据库中的数据,但RichTextBox提供了无效文件格式错误。当我希望编辑数据时,我将Web浏览器控件切换到后面并复制数据并将其粘贴到RichTextBox控件中,然后将RichTextBox控件放在前面。这工作正常,但一旦尝试更新,数据将以RTF格式保存,而不是HTML格式,然后当我尝试从数据库中再次提取数据时,浏览器不会将其解释为HTML。我如何将它从RichTextBox保存到HTML到数据库中,比如VBA应用程序可以? 我已经使用过这个在C#中:



创建一个WebBrowser。将内容从richtextbox复制并粘贴到网页浏览器。然后从web浏览器中读取html内容(DocumentText)属性。



编辑:
另一种方法:
使用Office Interop,创建一个Word文件,复制并粘贴到此文件中,然后另存为html。


I have to convert an Access VBA app over to VB.NET and one of the text boxes (format set to RichText) on the VBA app accepts a straight paste from a Word document including its formatting and saves it to the Access database as HTML... The HTML is then read from the database and displayed as it was originally pasted when retrieved. The issue I have now is, I can use a web browser control to display the data properly from the database, but the RichTextBox gives an Invalid File Format error. When I wish to edit the data I switch the web browser control to the back and copy the data and paste it into the RichTextBox control and then bring the RichTextBox control to the front. This works fine, but once an update is attempted, the data gets saved in RTF format which is not HTML and then when I try to bring it up again from the database, the browser doesn't interpret it as it is not HTML. How can I save it from the RichTextBox, to HTML into the database like the VBA app can?

解决方案

I've used this in C#:

Create a WebBrowser. Copy and paste the contents from your richtextbox to the webbrowser. And then read the html content (DocumentText) property from the webbrowser.

Edit: Another way: Use Office Interop, create a Word file, copy and paste into this file and then save as html.

这篇关于将WinForms RichTextBox数据保存为HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆