Saving formatted text from richtextbox

北战南征 提交于 2019-12-24 04:08:50

问题


Is there any way, to save formatted in database from richtextbox?

I've got richtextbox and some parts of text in this are bold.

string s=richtextbox.Text obviously doesn't work.

And If I can get this formatted text how to save it in Ms Sql Server 2005 ?


回答1:


Try using this to get the text and all rich text format codes.

string s = richTextBox.Rtf;



回答2:


There is one way to save the formatting to a database. I don't know what database system you use but you simply have to save all of the formatting properties- which are mostly alpha-numeric- in fields named the same as the properties themselves, in one single location, then each time your form loads also load these fields into their associated properties of the richtextbox control, from the database table. You can't name it Properties however. An odbc data source name can be automatically created connecting you to the database...but that is off the subject. But you do this using some dataset that you can save and update. But you can even save text colors and styles in this table.



来源:https://stackoverflow.com/questions/2578193/saving-formatted-text-from-richtextbox

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