//定义四个文本部分,便于分别应用不同的文本格式
string firstString = "大山的骄傲\r\n ";
string secondString = "——eheartcool其人\r\n\r ";
string thirdString = "\t七十年代末的一个夜晚,没有星星,也没有月亮," +"中国湖北恩施的小山村正沉浸在睡梦中,几声婴儿的哭嘀和紧接的爆竹声" + "冲破了夜的沉默,一个新的生命诞生了!\r\n";
string fourthString = "未完待续…… ";
rtb.Text = firstString;
rtb.Text += secondString;
rtb.Text += thirdString;
rtb.Text += fourthString;
//对标题应用格式
rtb.SelectionStart = 0;
rtb.SelectionLength = firstString.Length - 1;
rtb.SelectionFont = new System.Drawing.Font("黑体 ", 18F,
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
rtb.SelectionColor = System.Drawing.Color.Blue;
rtb.SelectionAlignment = HorizontalAlignment.Center;
//对副标题应用格式
rtb.SelectionStart = firstString.Length - 1;
rtb.SelectionLength = secondString.Length;
rtb.SelectionFont = new System.Drawing.Font("黑体 ", 12F,
System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
rtb.SelectionAlignment = HorizontalAlignment.Center;
rtb.SelectionColor = System.Drawing.Color.Black;
//对正文应用格式
rtb.SelectionStart = firstString.Length + secondString.Length -1;
rtb.SelectionLength = thirdString.Length;
rtb.SelectionFont = new System.Drawing.Font("宋体 ", 10F,
System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
rtb.SelectionColor = System.Drawing.Color.Black;
rtb.SelectionAlignment = HorizontalAlignment.Left;
//对结尾应用格式
rtb.SelectionStart = firstString.Length +
secondString.Length + thirdString.Length - 1;
rtb.SelectionLength = fourthString.Length;
rtb.SelectionFont = new System.Drawing.Font("宋体 ", 10F,
System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
rtb.SelectionColor = System.Drawing.Color.Black;
rtb.SelectionAlignment = HorizontalAlignment.Right;