How to save RichTextBox content in Access2010

只谈情不闲聊 提交于 2019-12-02 06:11:52
Renaud Bompuis

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.

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.
In Access, you can do this either by using the OLE Object data type or, better, the new Attachment data type.

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.

To work with attachments from .Net, here are a couple related questions:

You can just use the "Memo" field type if you're in Access 2007 or newer. Setting the TextFormat property to RichText will allow for 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. You can also insert formatting tags (e.g. ) this way if you'd like.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!