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

推荐订阅源

L
LangChain Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
U
Unit 42
腾讯CDC
D
Docker
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
I
InfoQ
Jina AI
Jina AI
爱范儿
爱范儿
宝玉的分享
宝玉的分享
博客园 - Franky
G
Google Developers Blog
P
Proofpoint News Feed

博客园 - 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