C#如何将Richtextbox中的内容用RTF格式输出

air123456789 2010-09-02 09:47:10
C#如何将Richtextbox中的内容用RTF格式输出

给Richtextbox控件赋值的格式为:

this.rtbText.Rtf = @"{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052"
+ @"{\fonttbl{\f0\fmodern\fprq6\fcharset134 \ 'cb\ 'ce\ 'cc\ 'e5;}{\f1\fnil\fcharset134 \ 'cb\ 'ce\ 'cc\ 'e5;}}"
+ @"{\colortbl;\red0\green0\blue0;}"
+ @"\viewkind4\uc1\pard\cf1\lang2052\f0\cf1 黑色 }";



问 怎么把Richtextbox控件里的内容以这种格式赋给字符串??
...全文
371 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
air123456789 2010-09-02
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 wuyazhe 的回复:]

那么直接保存可以么?
C# code
File.WriteAllText("rtfsample.txt", this.rtbText.Rtf);
[/Quote]
可以直接这样弄吗? 我试试哈。
assky124 2010-09-02
  • 打赏
  • 举报
回复
string str = this.richTextBox1.RTF;

貌似原来存数据库都是这么存的
兔子-顾问 2010-09-02
  • 打赏
  • 举报
回复
那么直接保存可以么?
File.WriteAllText("rtfsample.txt", this.rtbText.Rtf);
  • 打赏
  • 举报
回复
这个应该可以解决了吧!接点小分![Quote=引用 3 楼 wuyazhe 的回复:]
Save Rtf file from RichTextBox and Read Rtf file to RichTextBox
[/Quote]
air123456789 2010-09-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wuyazhe 的回复:]
Save Rtf file from RichTextBox and Read Rtf file to RichTextBox
[/Quote]
我不想把他保存成RTF格式的文件,我只想把他变成类似这样的字符串 怎么弄?


this.rtbText.Rtf = @"{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052"
+ @"{\fonttbl{\f0\fmodern\fprq6\fcharset134 \ 'cb\ 'ce\ 'cc\ 'e5;}{\f1\fnil\fcharset134 \ 'cb\ 'ce\ 'cc\ 'e5;}}"
+ @"{\colortbl;\red0\green0\blue0;}" + @"\viewkind4\uc1\pard\cf1\lang2052\f0\cf1 黑色 }";
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 cxz003 的回复:]
不是很明白 帮顶
[/Quote]
你真好!谢谢!
  • 打赏
  • 举报
回复
不是很明白 帮顶
wlgc123321 2010-09-02
  • 打赏
  • 举报
回复
看的我想该行做C#了 阿弥陀佛

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧