How to save RichTextBox content in Access2010

荒凉一梦 提交于 2019-12-20 03:55:18

问题


I'm creating a dictionary system, where words meaning is editable in RichTextBox (for user define FontSize, Color, etc...)

So how to can I save meaning RichTextBox content in the Access database in RTF format? And how to can I read this?


回答1:


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:

  • How to use Microsoft Access Database's Attachment Data Type?
  • Programmatically managing Microsoft Access Attachment-typed field with .NET



回答2:


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.



来源:https://stackoverflow.com/questions/18564968/how-to-save-richtextbox-content-in-access2010

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