如何使用数据绑定和sql保存richtextbox rtf [英] How to save richtextbox rtf using databinding and sql

查看:137
本文介绍了如何使用数据绑定和sql保存richtextbox rtf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的我有一个我在Visual Studio 2013中制作的#windows窗体程序

我有一个文本框设置为将文本属性数据绑定到我的sql数据库中的表

使用数据集

所以我的数据从文本框自动保存到数据库并回读到文本框

now

我需要将我的文本框更改为richtextbox,以便我可以加粗,更改颜色等字体。

我看不到如何使用数据绑定绑定和读回rtf属性

我试过这个



notesRichTextBox.DataBindings.Add(new Binding(Rtf,MyProgramDataSet.RTFTable,RTF));

但是当我重新打开表单时,它只会在colomn中放入一些rtf数据并且在richtextbox中没有显示任何内容

我尝试设置notesRichTextBox.Text = notesRichTextBox.Rtf并且它只显示了所有底层rtf代码/文字



请帮助

我也在开始尝试使用t设置数据绑定他是VisualStudio界面,但Rtf似乎不是一个选项

解决方案

参考 - 保存和恢复RichTextBox格式化文本。替代SaveFile / LoadFile [ ^ ]


CodeProject是你的朋友;表达对这种友谊的欣赏的最好方式是搜索CP寻找可能对你有帮助的文章和答案,并研究它们。



我认为这是直接的与你想做的事情有关:一个可以绑定到RTF属性的RichTextBox[ ^ ]。



另请参阅:[ ^ ]。

ok I have a c# windows forms program that I am making in Visual Studio 2013
I had a text box set to databinding text property to a table in my sql database
using a dataset
so my data was auto saved from text box to the database and read back to textbox
now
I needed to change my textbox to a richtextbox so that I could bold, change color etc.. the font.
I do not see how to bind and read back the rtf property using databinding
I tried this

notesRichTextBox.DataBindings.Add(new Binding("Rtf", MyProgramDataSet.RTFTable, "RTF"));
but it only put some rtf data in the colomn and displayed nothing back in the richtextbox when I reopened the form
I tried setting the notesRichTextBox.Text = notesRichTextBox.Rtf and it just showed all of the underlying rtf code/text

Please help
I also tried at the beginning to set the databinding using the VisualStudio interface but Rtf doesn't seem to be an option

解决方案

Refer - Saving and Restoring RichTextBox Formatted Text. Alternate to SaveFile/LoadFile[^]


CodeProject is your friend; the best way to show your appreciation for that friendship is to search CP for articles, and answers, that may assist you, and study them.

I think this is directly related to what you want to do: "A RichTextBox that can Bind to the RTF Property" [^].

Also, see: [^].


这篇关于如何使用数据绑定和sql保存richtextbox rtf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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