惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
雷峰网
雷峰网
博客园_首页
小众软件
小众软件
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
U
Unit 42
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗

博客园 - Anders06

A memory leak issue with WPF Command Binding 我也谈面试 附赠一份题目 败给了IEqualityComparer 标注随测量物体旋转问题 How to detect memory leak issue 图纸中角度标注算法 认真的程序员最可爱 Clean Code反案例:什么是不好的API 避免陷阱,重写Equals方法您需要注意的其中2个原则 What’s the problems with the following code 对象池 关于设计和设计文档的2个补充 SelectMany ConverAll & Exists 想探讨两个关于设计文档问题 Don‘t Cry for Me, Argentina 拒绝高姿态 Please avoid implement C# Destruction SOS: How to popup a HwndSource on topmost
SOS:利用WPF RichTextBox 提取RTF, 莫名丢掉了Underline样...
Anders06 · 2009-06-19 · via 博客园 - Anders06

主代码是这样写的:

 1richTextBox1.SelectAll();
 2richTextBox1.Selection.ApplyPropertyValue(Inline.TextDecorationsProperty, TextDecorations.Underline);
 3System.Drawing.FontStyle style = richTextBox1.DrawingFontStyle();
 4MessageBox.Show(style.ToString());     // <-- result: Underline
 5
 6string rtf = richTextBox1.RTF();
 7richTextBox1.LoadFromRTF(rtf);
 8richTextBox1.SelectAll();
 9style = richTextBox1.DrawingFontStyle();
10MessageBox.Show(style.ToString());    // <--  result: Regular    
11

运行的结果:
第一次显示: Underline
第二次显示: Regular
而RichTextBox里的字体始终是带有下划线的。个人分析的结果为 RichTextBox 提取RTF的字符串丢掉了Underline样式, 那么改如何修正呢?

提取RTF字符串:

RTF Extension

读取RTF:

Load RTF

 解析FontStyle:

Get FontStyle

完整的Source:/Files/anders06/RTFConvertor.zip