在System.Windows.Forms.RichTextBox存储任意应用程序数据 [英] Store arbitrary application data in System.Windows.Forms.RichTextBox

查看:540
本文介绍了在System.Windows.Forms.RichTextBox存储任意应用程序数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道的方式在的RichTextBox 存储任意数据,而无需用户能够看到这个数据? 2007年RTF规范包括注释(\atnid,\atnauthor,\annotation等等),但每当我将这些成的RichTextBox 小号 .RTF ,注释消失了(大概是因为的RichTextBox 不支持RTF注解。)我有<一个HREF =http://stackoverflow.com/questions/3831065/store-arbitrary-application-data-in-system-drawing-imaging-metafile>它是否可以存储图元文件图像内的信息相关的问题。这两种解决方案是可以接受的。 。TIA

Does anyone know of a way to store arbitrary data in a RichTextBox without the user being able to see this data? The 2007 RTF specification includes annotations ("\atnid", "\atnauthor", "\annotation", etc.) but whenever I insert these into a RichTextBox's .Rtf, the annotations disappear (presumably because the RichTextBox doesn't support RTF annotations.) I have a related question about whether it is possible to store the information inside a Metafile image. Either of these solutions would be acceptable. TIA.

我想要是这样的:

string objectXml = MySerialization.ToXml(object);
string commentRtfFragment = String.Format(@"{{\*\atnid MyApp}}{{\*\atnauthor MyApp}}{{\*\annotation {0}}}", objectXml);

string imageRtf = String.Format(@"{{\rtf1 {{\pict\wmetafile{0}\picw{1}\pich{2}\picwgoal{3}\pichgoal{4} {5}}}{6}}}",
    PixelMappingMode.MM_ANISOTROPIC, picw, pich, picwgoal, pichgoal, imageHex, commentRtfFragment);
richTextBox.SelectedRtf = imageRtf;



更新:应用程序元数据(注解)必须与RTF特定位置相对应。也将有每RichTextBox中多个注释(或者,如果你喜欢RTF文档。)我也想元数据与RTF坚持。因此,尽管它有可能坚持一个control.Tag元数据,那么我将不得不照顾将信息添加到数据库中的自己,每当用户编辑的RTF指出,不管怎样后确定的元数据的新位置编辑。

Update: The application metadata ("annotations") must correspond with particular locations in the RTF. There will also be multiple annotations per RichTextBox (or RTF document if you like.) I also want the metadata to persist with the RTF. So while it would be possible to persist the metadata in a control.Tag, then I would have to take care of adding the information to the database myself, noting whenever the user edited the RTF and somehow determine the new location of the metadata after the edit.

推荐答案

我觉得跟atandb响应将提供合适的解决方案。您可以使用\v和\v0来隐藏隐藏数据作为特定数据的特定位置的插图中的数据和访问。

I think the response with atandb will provide the right solution. You can use \v and \v0 to hide the data inbetween and access that hidden data as a specific data to that particular location.

我试着在RichTextBox的和RTF财产支持,它不通过跳过控制代码修改RTF内容。我有同样的问题,我幸运地结束了这个页面,现在我能有这样功能的一些注释/注释在RTF数据的任何位置。

I tried in the richtextbox and the rtf property supports that and it does not modify the rtf contents by skipping the control code. I had the same problem and I luckily ended up with this page and now I am able to have some annotation/comments like feature for any location in the rtf data.

非常感谢您的卡尔您的问题和 AtanDB 你的答案。

Thank you very much Carl for your question and AtanDB for your answer.

这篇关于在System.Windows.Forms.RichTextBox存储任意应用程序数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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