//
重点为是使用 SelectedRtf 属性
private
void button1_Click( object sender, EventArgs e )
{
//mergeRTF为并内容后的 RichTextBox 控件
mergeRTF.SelectionLength = 0; //不选内容
RichTextBox rtf = new RichTextBox(); //需要合并的RTF
StringBuilder s = new StringBuilder();
//第一个RTF文件
rtf.Text = "C#程序设计";
rtf.SelectAll();
Font f = null;
f = new Font( "宋体", 12 ,FontStyle.Bold);
rtf.SelectionFont = f; //字体
rtf.SelectionColor = Color.Red;
//加入
mergeRTF.SelectedRtf = rtf.SelectedRtf;
//第二个RTF文件
rtf.Text = "VB.NET程序设计";
rtf.SelectAll();
f = new Font( "楷体", 10, FontStyle.Italic );
rtf.SelectionFont = f; //字体
rtf.SelectionColor = Color.Gray;
//加入
mergeRTF.SelectedRtf = rtf.SelectedRtf;
//第三个RTF文件
rtf.Text = "美利坚合众国";
rtf.SelectAll();
f = new Font( "黑体", 25, FontStyle.Underline | FontStyle.Bold | FontStyle.Italic );
rtf.SelectionFont = f; //字体
rtf.SelectionColor = Color.Blue;
//加入
mergeRTF.SelectedRtf = rtf.SelectedRtf;
//第N个
//。。。。
}
原文:http://www.cnblogs.com/China3S/p/6213387.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!