在C#操纵富文本的更好的办法? [英] Better Way of Manipulating RichText in C#?

查看:1151
本文介绍了在C#操纵富文本的更好的办法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建和复制到剪贴板一些富文本标准格式化像粗体/斜体,缩进等等。我现在做的方式似乎有点不雅...我创建一个RichTextBox项目,并通过像这样将我的格式:

I need to create and copy to the clipboard some RichText with standard "formatting" like bold/italics, indents and the like. The way I'm doing it now seems kind of inelegant... I'm creating a RichTextBox item and applying my formatting through that like so:

RichTextBox rtb = new RichTextBox();
Font boldfont = new Font("Times New Roman", 10, FontStyle.Bold);
rtb.Text = "sometext";
rtb.SelectAll()
rtb.SelectionFont = boldfont;
rtb.SelectionIndent = 12;

有一定是一个更好的办法,但在搜索我无法前来了几个小时后,了更好的东西。任何想法

There has got to be a better way, but after a few hours of searching I was unable to come up with anything better. Any ideas?

编辑:没有显示
RichTextBox的(RTB)/在窗体上的任意位置绘制。我只是使用对象格式化我的富文本。

The RichTextBox (rtb) is not displayed/drawn anywhere on a form. I'm just using the object to format my RichText.

推荐答案

是这个项目是否有帮助?

Is this project helpful?

HTTP:// WWW。 codeproject.com/KB/string/nrtftree.aspx

这篇关于在C#操纵富文本的更好的办法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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