简体   繁体   English

如何在Access2010中保存RichTextBox内容

[英]How to save RichTextBox content in Access2010

I'm creating a dictionary system, where words meaning is editable in RichTextBox (for user define FontSize, Color, etc...) 我正在创建一个词典系统,其中的单词含义可以在RichTextBox编辑(供用户定义FontSize,Color等...)

So how to can I save meaning RichTextBox content in the Access database in RTF format? 那么,如何以RTF格式将有意义的RichTextBox内容保存在Access数据库中? And how to can I read this? 我该如何阅读?

Native Rich text in Access 2007/2010/2013 uses a subset of HTML, not RTF, so unless you want to convert to/from RTF<>HTML when you load/save your data, you will have to find another way to store your formatted text. Access 2007/2010/2013中的本机富文本使用HTML的一部分,而不是RTF,因此,除非要在加载/保存数据时与RTF <> HTML进行相互转换,否则您将不得不寻找另一种存储您的数据的方法。格式化的文本。

Since the WPF RichText control uses RTF, the best way to save data in an Access database would probably be to use a binary blob. 由于WPF RichText控件使用RTF,因此在Access数据库中保存数据的最佳方法可能是使用二进制Blob。
In Access, you can do this either by using the OLE Object data type or, better, the new Attachment data type. 在Access中,可以通过使用OLE Object数据类型或者更好的是新的Attachment数据类型来执行此操作。

If you want to be able to do a text search on the text entered through the RichText control, you should probably add another Memo field to your database containing the cleaned-up, pure-text version of the data. 如果希望能够对通过RichText控件输入的文本进行文本搜索,则可能应该向数据库中添加另一个“ Memo字段,其中包含数据的纯文本版本。

To work with attachments from .Net, here are a couple related questions: 要使用.Net的附件,这里有几个相关的问题:

You can just use the "Memo" field type if you're in Access 2007 or newer. 如果您使用的是Access 2007或更高版本,则只能使用“备注”字段类型。 Setting the TextFormat property to RichText will allow for RTF. 将TextFormat属性设置为RichText将允许RTF。

To edit it, just use a text box with the appropriate field set as its control source. 要对其进行编辑,只需使用设置了适当字段的文本框作为其控制源。

To read it via code, access the .Value property. 要通过代码读取它,请访问.Value属性。 You can also insert formatting tags (eg 您也可以插入格式标记(例如 ) this way if you'd like. ),如果您愿意的话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM